misc/libfreetype/builds/atari/deflinejoiner.awk
author Xeli
Sat, 04 Feb 2012 16:22:46 +0100
changeset 6622 01889d5bc79b
parent 5172 88f2e05288ba
permissions -rw-r--r--
Rewrote the Ammomenu: Added landscape ammomenu At the moment MOBILE indicates landscape, but we could just as easily make a variable out of it Draw to texture once uVariables.AmmoMenuInvalidated indicates a new ammo menu needs to be drawn, see uTeams and uAmmos Slot/Cellsize is dependent on uConsts.AMSlotSize this should make it easier to scale the ammo menu on smaller screens AmmoRect AmmoRect indicates where and how big the ammo menu is, this makes positioning a bit easier imo, because you only need to change the position at one single point needs testing on the iphone (and other systems as well ofcourse..)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
#!/usr/bin/env awk
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
function shift( array, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
                junk, elm0, l )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
  elm0 = array[0]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
  for ( l = 0; l < asorti( array, junk ) - 1; l++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
    array[l] = array[l+1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
  delete array[l]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
  return elm0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
function init_cpp_src_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
  logical_line = ""
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
  delete break_pos 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
function shift_valid_bp( array, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
                         junk, elm )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
  elm = -1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  if ( 0 < asorti( array, junk ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
    do {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
      elm = shift( array )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
    } while ( 0 > elm );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  return elm
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
function check_cpp_src_line_break_pos( \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
                                       i, junk )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  printf( "break_pos:" )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  for ( i = 0; i < asorti( break_pos, junk ); i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    printf( " %d", break_pos[i] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  printf( "\n" )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
function check_cpp_src_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  printf( "logical_line[%s]\n", logical_line )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  check_cpp_src_line_break_pos()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
function append_line( phys_line, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
                      filt_line, bp_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  filt_line = phys_line
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  sub( /\\$/, " ", filt_line )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  logical_line    = logical_line filt_line
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  bp_len = asorti( break_pos, junk )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  break_pos[bp_len] = length( logical_line ) - 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
function print_line( \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
                     c0, c1, i, junk, part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
  c0 = 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  while( asorti( break_pos, junk ) > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    if ( ( c1 = shift_valid_bp( break_pos ) ) < 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
      part_str = substr( logical_line, c0 + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      printf( "%s\n", part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      return
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    part_str = substr( logical_line, c0 + 1, c1 - c0 + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    gsub( / $/, "\\", part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    printf( "%s\n", part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    c0 = c1 + 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  part_str = substr( logical_line, c0 + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  printf( "%s\n", part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
function shrink_spaces( pos, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
                        tail, removed_length, k )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  tail = substr( logical_line, pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  sub( /^[ \t]+/, " ", tail )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
  removed_length = length( logical_line ) - pos - length( tail ) + 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
  logical_line = substr( logical_line, 0, pos - 1 ) tail
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  for ( k = 0; k < asorti( break_pos, junk ); k++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    if ( ( pos + removed_length ) <= break_pos[k] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      break_pos[k] = break_pos[k] - removed_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    else if ( pos <= break_pos[k] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      break_pos[k] = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
  return removed_length
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
function shrink_spaces_to_linebreak( pos, \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
                                     junk, part_str, removed_length, i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  for ( i = 0; i < asorti( break_pos, junk ) && break_pos[i] < pos ; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  if ( break_pos[i] < 1 ) 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  part_str = substr( logical_line, pos, break_pos[i] - pos + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  sub( /^[ \t]+/, " ", part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  removed_length = ( break_pos[i] - pos + 1 ) - length( part_str )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
  tail = substr( logical_line, pos + removed_length )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  logical_line = substr( logical_line, 0, pos - 1 ) tail
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  for ( ; i < asorti( break_pos, junk ); i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    break_pos[i] -= removed_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  return removed_length
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
function delete_linebreaks_in_2nd_token( \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
                                           tail, paren_depth, junk, i, j, k, l )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  if ( logical_line ~ /^[ \t]*#[ \t]*define[ \t]+[0-9A-Za-z_]+\(/ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    tail = logical_line
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    sub( /^[ \t]*#[ \t]*define[ \t]+[0-9A-Za-z_]+/, "", tail )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    paren_depth = 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    l = 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    i = length( logical_line ) - length( tail ) + 1 # seek to the 1st op paren
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    j = i
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    do {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      if ( substr( logical_line, j, 2 ) ~ /[ \t][ \t]/ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        l = shrink_spaces( j );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      else if ( substr( logical_line, j, 1 ) == "(" )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
        paren_depth += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      else if ( substr( logical_line, j, 1 ) == ")" )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
        paren_depth -= 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
      j += 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    } while ( j < length( logical_line ) && paren_depth != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    for ( k = 0; k < asorti( break_pos, junk ); k++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      if ( i <= break_pos[k] && break_pos[k] < j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
        break_pos[k] = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    if ( l > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      shrink_spaces_to_linebreak( j );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
BEGIN{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
  init_cpp_src_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
  append_line( $0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  if ( $0 !~ /\\$/ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    delete_linebreaks_in_2nd_token()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    print_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    init_cpp_src_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
}
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
END{
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  if ( 0 < length( logical_line ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    delete_linebreaks_in_2nd_token()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    print_line()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
}