Loading ...
Sorry, an error occurred while loading the content.

Re: [jasspa] C formatting bug in RC

Expand Messages
  • Jon Green
    ... You can use the hilighting to pick up on some faults. I ve added this one to my hit list for C . To use add the following to myc.emf . Jon. -- ; Pick up
    Message 1 of 4 , Jan 27, 2004
    • 0 Attachment
      Jeremy Cowgar wrote:
      > On Mon, 2004-01-26 at 19:25, Jon Green wrote:
      >
      >>Jeremy Cowgar wrote:
      >>
      >>>Greetings, I have found the following C formatting bug:
      >>>
      >>>int main(void) {
      >>> int a = do_something(name, age, birth_date,
      >>> address("123 main st.\n" \
      >>> "Small Town, NY USA 40392"));
      >>> printf("Goofy");
      >>> }
      >>>
      >>
      >>The following works correctly:-
      >>
      >>int main(void) {
      >> int a = do_something(name, age, birth_date,
      >> address("123 main st.\n"
      >> "Small Town, NY USA 40392"));
      >> printf("Goofy");
      >>}
      >>
      >>I suggest you fix the code in this case.
      >
      >
      >
      > Eek! Although C is not my primary, or even secondary language, I'm not
      > new to it and now I find out I've been doing things wrong all this time.
      > Everywhere in my code I put that in when I break strings on multiple
      > lines... funny thing is, gcc never complained about it, but it also
      > works great without it and going back to the books, you are obviously
      > right.
      >
      > I have corrected my code and MicroEmacs is happy, gcc is happy and I'm
      > happy :-)
      >
      > Sorry to blame MicroEmacs for my bad programming.
      >
      > Jeremy

      You can use the hilighting to pick up on some
      faults. I've added this one to my hit list for 'C'.

      To use add the following to "myc.emf".

      Jon.

      --

      ; Pick up bogus 'C' constructs extension
      !if &and &sin "h" .fhook-c.setup &band .hilight.flags 0x02
      ; Detect a for loop with no body - put semi-colon on next line, i.e.
      ; for (i = 1; i < 10; i++);
      ; { ... }
      hilight .hilight.c 2 "for[ \t]*([^()]*)[ \t]*;" .scheme.hlred
      ; Detect a bad 'if' statement that is terminated with ';' e.g.
      ; if (i < x);
      ; { ... }
      hilight .hilight.c 2 "if[ \t]*([^()]*)[ \t]*;" .scheme.hlred
      ; Detect a spurious '\' at the end of the line that is
      ; not a string or #define. i.e.
      ; char *d = "This is a " \
      ; "Duff string continuation";
      hilight .hilight.c 2 "\\\\$" .scheme.hlred
      !endif
    Your message has been successfully submitted and would be delivered to recipients shortly.