groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] Duff's Device lurking in refer.cpp


From: G. Branden Robinson
Subject: [groff] Duff's Device lurking in refer.cpp
Date: Tue, 26 Jun 2018 11:37:39 -0400
User-agent: NeoMutt/20170113 (1.7.2)

I enjoyed this Easter egg; maybe you will too.

src/preproc/refer/refer.cpp:
  for (--argc, ++argv;
       !finished_options && argc > 0 && argv[0][0] == '-'
       && argv[0][1] != '\0';
       argv++, argc--) {
    const char *opt = argv[0] + 1; 
    while (opt != 0 && *opt != '\0') {
      switch (*opt) {
      case 'C':
        compatible_flag = 1;
        opt++;
        break;
// ...
      case '-':
        if (opt[1] == '\0') {
          finished_options = 1;
          opt++;
          break;
        }
        if (strcmp(opt,"-version")==0) {
      case 'v': // <-- a gibbon on the syntax tree
          printf("GNU refer (groff) version %s\n", Version_string);
          exit(0);
          break;
        }
        if (strcmp(opt,"-help")==0) {
          usage(stdout);
          exit(0);
          break;
        }
        // fall through
      default:
        error("unrecognized option '%1'", *opt);
        usage(stderr);
        exit(1);
        break;
      }
    }
  }

-- 
Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]