Subversion Repositories DevTools

Rev

Rev 313 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 313 Rev 317
Line 85... Line 85...
85
char                rtags[10]           = { 0 };
85
char                rtags[10]           = { 0 };
86
int                 tflg                = 0;
86
int                 tflg                = 0;
87
int                 vflg                = 0;
87
int                 vflg                = 0;
88
int                 wflg                = 0;
88
int                 wflg                = 0;
89
int                 whitespace          = WS_UNKNOWN;
89
int                 whitespace          = WS_UNKNOWN;
-
 
90
int                 nl = FALSE;
90
 
91
 
91
static int          linelen = 0;
92
static int          linelen = 0;
92
static char         linebuffer[ 32*1024 ];      /* 32k line buffer */
93
static char         linebuffer[ 32*1024 ];      /* 32k line buffer */
93
 
94
 
94
static String_t     mstr;
-
 
95
 
95
 
96
static void         PUTC(int c);
96
static void         PUTC(int c);
97
static void         PUTS(const char *s);
97
static void         PUTS(const char *s);
98
static void         FLUSH(void);
98
static void         FLUSH(void);
99
 
99
 
Line 202... Line 202...
202
    argc--, argv++;
202
    argc--, argv++;
203
 
203
 
204
/* Import CMDFILE environment variable */
204
/* Import CMDFILE environment variable */
205
    if (getenv("CMDFILE"))
205
    if (getenv("CMDFILE"))
206
    {
206
    {
-
 
207
printf( "PARSE ENV OPTS\n" );
207
        parse_short_argument( getenv("CMDFILE" ) );
208
        parse_short_argument( getenv("CMDFILE" ) );
208
    }
209
    }
209
 
210
 
210
/* Standard options (only allowed as first command) */
211
/* Standard options (only allowed as first command) */
211
    if (argc > 0 && *argv[0] == '-')
212
    if (argc > 0 && *argv[0] == '-')
Line 238... Line 239...
238
        if (!eflg)  verbose( "  Not processing escape sequences" );
239
        if (!eflg)  verbose( "  Not processing escape sequences" );
239
        if (eflg)   verbose( "  Level %d escape sequence processing", eflg );
240
        if (eflg)   verbose( "  Level %d escape sequence processing", eflg );
240
    }
241
    }
241
 
242
 
242
/* Process remaining */
243
/* Process remaining */
243
    StringInit( &mstr, NULL, MACRO_MAX );       /* macro resource */
-
 
244
    if (argc > 0)
244
    if (argc > 0)
245
    {
245
    {
246
        int nl = FALSE;
-
 
247
        int argi;
246
        int argi;
-
 
247
        nl = FALSE;
248
 
248
 
249
        for (argi = 0; argc > 0; argi++)
249
        for (argi = 0; argc > 0; argi++)
250
        {
250
        {
251
            register char *s = argv[0];
-
 
252
            register int c = '\0';
-
 
253
 
-
 
254
            if (vflg > 2)
251
            if (vflg > 2)
255
                verbose( "ARGV[%d]%s", argi, s );
252
                verbose( "ARGV[%d]%s", argi, argv[0] );
256
 
-
 
257
            while ((c = *s++) != '\0')
-
 
258
            {
-
 
259
                /*
-
 
260
                 *  Escape processing ...
-
 
261
                 */
-
 
262
                if (eflg && c == '\\' && *s)
-
 
263
                {
-
 
264
                    switch (c = *s++)
-
 
265
                    {
-
 
266
                    case '\n':                  /* concat line */
-
 
267
                        nl = TRUE, c = '\0';
-
 
268
                        break;
-
 
269
                    case 'n':                   /* \n */
-
 
270
                        c = NEWLINE;
-
 
271
                        break;
-
 
272
                    case '\\':                  /* backslash */
-
 
273
                        break;
-
 
274
                    default:
-
 
275
                        if (eflg >= 2) {        /* extended */
-
 
276
                            switch (c)
-
 
277
                            {
-
 
278
                            case 'a': c = '\007'; break;
-
 
279
                            case 'b': c = '\b'; break;
-
 
280
                            case 'c': nflg = 0; break;
-
 
281
                            case 'f': c = '\f'; break;
-
 
282
                            case 'r': c = '\r'; break;
-
 
283
                            case 't': c = '\t'; break;
-
 
284
                            case 'v': c = (int) 0x0B; break;
-
 
285
                            case '0': case '1': case '2': case '3':
-
 
286
                            case '4': case '5': case '6': case '7':
-
 
287
                                c -= '0';
-
 
288
                                if (*s >= '0' && *s <= '7')
-
 
289
                                    c = c * 8 + (*s++ - '0');
-
 
290
                                if (*s >= '0' && *s <= '7')
-
 
291
                                    c = c * 8 + (*s++ - '0');
-
 
292
                                break;
-
 
293
                            default:
-
 
294
                                PUTC('\\');     /* unknown echo */
-
 
295
                                break;
-
 
296
                            }
-
 
297
                        } else {
-
 
298
                            PUTC('\\');         /* unknown echo */
-
 
299
                        }
-
 
300
                        break;
-
 
301
                    }
-
 
302
                }
-
 
303
 
-
 
304
                /*
-
 
305
                 *  Macros ...
-
 
306
                 */
-
 
307
                else if (Mflg == 0 && c == MACROCHAR && *s)
-
 
308
                {
-
 
309
                    const char *str;
-
 
310
 
-
 
311
                    StringZero(&mstr);
-
 
312
                    s += macro(&mstr, s);
-
 
313
                    if ((str = StringData(&mstr)) != NULL && str[0]) {
-
 
314
                        PUTS(str);
-
 
315
                        nl = FALSE;
-
 
316
                    }
-
 
317
                    c = '\0';
-
 
318
                }
-
 
319
 
-
 
320
                /*
-
 
321
                 *  Default output ...
-
 
322
                 */
-
 
323
                if (c != '\0')
-
 
324
                {
-
 
325
                    if (nl && (c == ' ' || c == '\t') && wflg)
-
 
326
                        continue;               /* eat leading white space */
-
 
327
 
-
 
328
                    if (c == '\n' || c == NEWLINE)
-
 
329
                        nl = TRUE;
-
 
330
                    else nl = FALSE;
-
 
331
 
253
 
332
                    PUTC(c);                    /* output character */
-
 
333
                }
254
            process_string ( argv[0] );
334
            }
-
 
335
 
255
 
336
            argc--, argv++;                     /* next argument */
256
            argc--, argv++;                     /* next argument */
337
 
257
 
338
            if (argc > 0 && nl == FALSE)
258
            if (argc > 0 && nl == FALSE)
339
            {                                   /* seperator */
259
            {                                   /* seperator */
Line 365... Line 285...
365
        tmp_name[0] = '\0';                     /* stop cleanup of tmp_name */
285
        tmp_name[0] = '\0';                     /* stop cleanup of tmp_name */
366
    }
286
    }
367
    return (0);
287
    return (0);
368
}
288
}
369
 
289
 
-
 
290
/*----------------------------------------------------------------------------
-
 
291
** FUNCTION           : process_string
-
 
292
**
-
 
293
** DESCRIPTION        : Process a string
-
 
294
**                      It may be from an argument, it may be from a macro
-
 
295
**
-
 
296
**
-
 
297
** INPUTS             : s               - String to process
-
 
298
**
-
 
299
** RETURNS            : Nothing
-
 
300
**
-
 
301
----------------------------------------------------------------------------*/
-
 
302
 
-
 
303
void process_string (register char *s )
-
 
304
{
-
 
305
    register int c = '\0';
-
 
306
 
-
 
307
    while ((c = *s++) != '\0')
-
 
308
    {
-
 
309
        /*
-
 
310
         *  Escape processing ...
-
 
311
         */
-
 
312
        if (eflg && c == '\\' && *s)
-
 
313
        {
-
 
314
            switch (c = *s++)
-
 
315
            {
-
 
316
            case '\n':                  /* concat line */
-
 
317
                nl = TRUE, c = '\0';
-
 
318
                break;
-
 
319
            case 'n':                   /* \n */
-
 
320
                c = NEWLINE;
-
 
321
                break;
-
 
322
            case '\\':                  /* backslash */
-
 
323
                break;
-
 
324
            default:
-
 
325
                if (eflg >= 2) {        /* extended */
-
 
326
                    switch (c)
-
 
327
                    {
-
 
328
                    case 'a': c = '\007'; break;
-
 
329
                    case 'b': c = '\b'; break;
-
 
330
                    case 'c': nflg = 0; break;
-
 
331
                    case 'f': c = '\f'; break;
-
 
332
                    case 'r': c = '\r'; break;
-
 
333
                    case 't': c = '\t'; break;
-
 
334
                    case 'v': c = (int) 0x0B; break;
-
 
335
                    case '0': case '1': case '2': case '3':
-
 
336
                    case '4': case '5': case '6': case '7':
-
 
337
                        c -= '0';
-
 
338
                        if (*s >= '0' && *s <= '7')
-
 
339
                            c = c * 8 + (*s++ - '0');
-
 
340
                        if (*s >= '0' && *s <= '7')
-
 
341
                            c = c * 8 + (*s++ - '0');
-
 
342
                        break;
-
 
343
                    default:
-
 
344
                        PUTC('\\');     /* unknown echo */
-
 
345
                        break;
-
 
346
                    }
-
 
347
                } else {
-
 
348
                    PUTC('\\');         /* unknown echo */
-
 
349
                }
-
 
350
                break;
-
 
351
            }
-
 
352
        }
-
 
353
 
-
 
354
        /*
-
 
355
         *  Macros ...
-
 
356
         */
-
 
357
        else if (Mflg == 0 && c == MACROCHAR && *s)
-
 
358
        {
-
 
359
            const char *str;
-
 
360
            String_t     mstr;
-
 
361
 
-
 
362
            StringInit( &mstr, NULL, MACRO_MAX );       /* macro resource */
-
 
363
            s += macro(&mstr, s);
-
 
364
            if ((str = StringData(&mstr)) != NULL && str[0]) {
-
 
365
                PUTS(str);
-
 
366
                nl = FALSE;
-
 
367
            }
-
 
368
            free( StringData(&mstr) );
-
 
369
            c = '\0';
-
 
370
        }
-
 
371
 
-
 
372
        /*
-
 
373
         *  Default output ...
-
 
374
         */
-
 
375
        if (c != '\0')
-
 
376
        {
-
 
377
            if (nl && (c == ' ' || c == '\t') && wflg)
-
 
378
                continue;               /* eat leading white space */
-
 
379
 
-
 
380
            if (c == '\n' || c == NEWLINE)
-
 
381
                nl = TRUE;
-
 
382
            else nl = FALSE;
-
 
383
 
-
 
384
            PUTC(c);                    /* output character */
-
 
385
        }
-
 
386
    }
-
 
387
    
-
 
388
}
370
 
389
 
371
static void
390
static void
372
__PUTC(int c)
391
__PUTC(int c)
373
{
392
{
374
    int     flushit = 0;
393
    int     flushit = 0;
Line 579... Line 598...
579
  \\v                   Vertical tab.\n\
598
  \\v                   Vertical tab.\n\
580
  \\NNN                 The character whose ASCII code is NNN (octal).\n");
599
  \\NNN                 The character whose ASCII code is NNN (octal).\n");
581
printf("\n\
600
printf("\n\
582
Without -M, the following macros are recognized and executed:\n\
601
Without -M, the following macros are recognized and executed:\n\
583
\n\
602
\n\
584
  @(env,var)           Get text from named EnvVar \n\
603
  @(env,var)           Get text from named EnvVar\n\
-
 
604
  @(envmacro,var)      Process text from named EnvVar\n\
585
  @(dosify,path)       Convert the specify path to DOS conventions (8.3)\n\
605
  @(dosify,path)       Convert the specify path to DOS conventions (8.3)\n\
586
  @(realpath,path)     Determine the absolute path, removing . and ..\n\
606
  @(realpath,path)     Determine the absolute path, removing . and ..\n\
587
                       and resolving relative references\n\
607
                       and resolving relative references\n\
588
  @(shortpath,path)    Convert the path into a short path (WIN32 specific).\n\
608
  @(shortpath,path)    Convert the path into a short path (WIN32 specific).\n\
589
  @(vhost,ident)       Override the default host (Unix or WIN32).\n\
609
  @(vhost,ident)       Override the default host (Unix or WIN32).\n\