History

docproc: abstract terminating lines at first space

Cleaner code. Also fixes a bug when F or P directives didn't in fact have space.

Jani Nikula committed 10 years ago

Commit 1dcdad01 parent a48dc451 file · +21 −13Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/docproc.c+21−13
@@ -430,6 +430,21 @@ static void find_all_symbols(char *filename) · 429 unmodified lines
430 }430 }
431}431}
432 432
433/*
434 * Terminate s at first space, if any. If there was a space, return pointer to
435 * the character after that. Otherwise, return pointer to the terminating NUL.
436 */
437static char *chomp(char *s)
438{
439 while (*s && !isspace(*s))
440 s++;
441
442 if (*s)
443 *s++ = '\0';
444
445 return s;
446}
447
433/* Return pointer to directive content, or NULL if not a directive. */448/* Return pointer to directive content, or NULL if not a directive. */
434static char *is_directive(char *line)449static char *is_directive(char *line)
435{450{
@@ -460,27 +475,22 @@ static void parse_file(FILE *infile) · 24 unmodified lines
460 continue;475 continue;
461 }476 }
462 477
463 s = p + 1;
464 switch (*p++) {478 switch (*p++) {
465 case 'E':479 case 'E':
466 while (*s && !isspace(*s)) s++;480 chomp(p);
467 *s = '\0';
468 externalfunctions(p);481 externalfunctions(p);
469 break;482 break;
470 case 'I':483 case 'I':
471 while (*s && !isspace(*s)) s++;484 chomp(p);
472 *s = '\0';
473 internalfunctions(p);485 internalfunctions(p);
474 break;486 break;
475 case 'D':487 case 'D':
476 while (*s && !isspace(*s)) s++;488 chomp(p);
477 *s = '\0';
478 symbolsonly(p);489 symbolsonly(p);
479 break;490 break;
480 case 'F':491 case 'F':
481 /* filename */492 /* filename */
482 while (*s && !isspace(*s)) s++;493 s = chomp(p);
483 *s++ = '\0';
484 /* function names */494 /* function names */
485 while (isspace(*s))495 while (isspace(*s))
486 s++;496 s++;
@@ -488,16 +498,14 @@ static void parse_file(FILE *infile) · 1 unmodified line
488 break;498 break;
489 case 'P':499 case 'P':
490 /* filename */500 /* filename */
491 while (*s && !isspace(*s)) s++;501 s = chomp(p);
492 *s++ = '\0';
493 /* DOC: section name */502 /* DOC: section name */
494 while (isspace(*s))503 while (isspace(*s))
495 s++;504 s++;
496 docsection(p, s);505 docsection(p, s);
497 break;506 break;
498 case 'C':507 case 'C':
499 while (*s && !isspace(*s)) s++;508 chomp(p);
500 *s = '\0';
501 if (findall)509 if (findall)
502 findall(p);510 findall(p);
503 break;511 break;