~ubuntu-branches/ubuntu/utopic/linux86/utopic

« back to all changes in this revision

Viewing changes to cpp/cpp.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-07 20:33:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071207203339-uonmnsb2j32kh0sg
Tags: 0.16.17-2ubuntu1
* Merge with Debian; remaining changes:
  - Build elks-libc for lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
static int  get_if_expression P((void));
112
112
static int_type get_expression P((int));
113
113
static int_type get_exp_value P((void));
114
 
static void gen_substrings P((char *, char *, int));
 
114
static void gen_substrings P((char *, char *, int, int));
115
115
static char * insert_substrings P((char *, struct arg_store *, int));
116
116
 
117
117
int
134
134
 
135
135
         if( ch == TK_WORD )
136
136
         {
137
 
            struct token_trans *p;
138
 
            if( p=is_ckey(curword, strlen(curword)) )
 
137
            struct token_trans *p = is_ckey(curword, strlen(curword)) ;
 
138
            if( p )
139
139
               return p->token;
140
140
         }
141
141
 
329
329
            }
330
330
 
331
331
            /* We have arguments to process so lets do so. */
332
 
            gen_substrings(ptr->name, ptr->value, ptr->arg_count);
 
332
            gen_substrings(ptr->name, ptr->value, ptr->arg_count, ptr->varargs);
333
333
 
334
334
            /* Don't mark macros with arguments as in use, it's very 
335
335
             * difficult to say what the correct result would be so
551
551
   fprintf(stderr, "\b", ch);
552
552
#endif
553
553
   if(ch == 0) return;  /* Hummm */
554
 
   if(ch == EOF) ch=EOT; /* EOF is pushed back as ^Z */
 
554
   if(ch == EOF) ch=EOT; /* EOF is pushed back as a normal character. */
555
555
   ch &= 0xFF;
556
556
 
557
557
   if(unputc&0xFF000000) 
822
822
                  cc++;
823
823
                  ptr->arg_count++;
824
824
                  ch=gettok_nosub();
 
825
                  if( ch == TK_ELLIPSIS ) {
 
826
                     ptr->varargs = 1;
 
827
                     ch=gettok_nosub();
 
828
                     if (ch == ',') ch = '*'; /* Force error if not ')' */
 
829
                  }
825
830
                  if( ch == ')' ) break;
826
831
                  if( ch == ',' ) continue;
827
832
               }
1247
1252
}
1248
1253
 
1249
1254
void
1250
 
gen_substrings(macname, data_str, arg_count)
 
1255
gen_substrings(macname, data_str, arg_count, is_vararg)
1251
1256
char * macname;
1252
1257
char * data_str;
1253
1258
int arg_count;
 
1259
int is_vararg;
1254
1260
{
1255
1261
   char * mac_text = 0;
1256
1262
   struct arg_store *arg_list;
1289
1295
         if ( ch == '(' ) paren_count++;
1290
1296
         if ( ch == '"' || ch == '\'' ) { in_quote = 1; quote_char = ch; }
1291
1297
         if (paren_count == 0 && ch == ',' ) {
1292
 
            commas_found++; continue;
 
1298
            commas_found++; 
 
1299
            if (commas_found < arg_count)
 
1300
               continue;
1293
1301
         }
1294
1302
         if ( ch == ')' ) {
1295
1303
            if (paren_count == 0) break;
1297
1305
         }
1298
1306
      }
1299
1307
      args_found = 1;
1300
 
      /* Too many args; ignore rest */
1301
 
      if (commas_found >= arg_count ) continue;
1302
 
      ac = commas_found;
 
1308
      /* Too many args, deal with, or ignore, the rest. */
 
1309
      if (commas_found >= arg_count) {
 
1310
         if(arg_count == 0) continue;
 
1311
         ac = arg_count-1;
 
1312
      } else
 
1313
         ac = commas_found;
 
1314
 
1303
1315
      if (arg_list[ac].value == 0) {
1304
1316
         cc = len = 0;
1305
1317
         arg_list[ac].in_define = def_count;
1322
1334
 
1323
1335
   if (commas_found || args_found) args_found = commas_found+1;
1324
1336
 
1325
 
   if( arg_count != args_found )
1326
 
      cerror("Incorrect number of macro arguments");
 
1337
   if( arg_count == 0 && args_found != 0 )
 
1338
      cerror("Arguments given to macro without them.");
 
1339
   else if( !is_vararg && arg_count != args_found )
 
1340
      cwarn("Incorrect number of macro arguments");
1327
1341
 
1328
1342
   mac_text = insert_substrings(data_str, arg_list, arg_count);
1329
1343