top | item 45932093

(no title)

dietrichepp | 3 months ago

Somebody wanted to set breakpoints in their C code by marking them with a comment (note “d” for “debugger”):

  //d
You can get a list of them with a single Awk line.

  awk -F'//d[[:space:]]*' 'NF > 1 {print FILENAME ":" FNR " " $2}' source/*.c
You can even create a GDB script, pretty easily.

(IMO, easier still to configure your editor to support breakpoints, but I’m not the one who chose to do it this way.)

discuss

order

kazinator|3 months ago

Why are you using the locale-specific [:space:] on source code? In your C source code, are you using spaces other than ASCII 0x20?

Would you have //d<0xA0>rest of comment?

Or some fancy Unicode space made using several UTF-8 bytes?

wtallis|3 months ago

Tab characters can also be found in source code.

dietrichepp|3 months ago

> Why are you using the locale-specific [:space:] on source code?

Because it’s the one I remembered first, it worked, and I didn’t think that it needed any improvement. In fact, I still don’t think it needs any improvement.