X-Git-Url: http://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/075a8578cc9467d07ccff7688bfd0f4855712e1c..95d8e7745d9b00097d50d9903d62c48268324e7a:/scripts/gen-options.awk diff --git a/scripts/gen-options.awk b/scripts/gen-options.awk index 80adcb4..c6d361c 100755 --- a/scripts/gen-options.awk +++ b/scripts/gen-options.awk @@ -123,6 +123,10 @@ END { } BEGIN { + # Check if "\\\\" in substitutions gives just one backslash. + bs = "x"; sub(/x/, "\\\\", bs); + bs = (length(bs) == 1 ? "\\\\" : "\\"); + has_actions = 0 sopt_string = "" num_options = 0 @@ -238,7 +242,7 @@ END { lopt_strings = add_to_strtab(lopt_strings, sorted_options[i], offsets) } gsub(/[^ ]+/, "\"&", lopt_strings) - gsub(/ /, "\\0\"\n\t", lopt_strings) + gsub(/ /, bs"0\"\n\t", lopt_strings) print "static const char lopt_strings[] =" print "\t" lopt_strings "\";\n" @@ -318,8 +322,8 @@ END { help_offsets[opt] = help_pos help_pos += length(help) + 1 - gsub(/"/, "\\\"", help) - gsub(/\n/, "\\n\"\n\t \"", help) + gsub(/"/, bs"\"", help) + gsub(/\n/, bs"n\"\n\t \"", help) help = "\tPN_(\"" opt "\",\n\t \"" help "\")" } }