[GODCC][COMMITTED] Use new string breaks
Jose E. Marchesi
jemarch@gnu.org
Wed Apr 23 23:49:41 GMT 2025
---
src/godcc-list.a68 | 6 ++--
src/godcc.a68 | 78 +++++++++++++++++++++++-----------------------
src/http.a68 | 24 +++++++-------
src/json.a68 | 21 +++++++------
4 files changed, 65 insertions(+), 64 deletions(-)
diff --git a/src/godcc-list.a68 b/src/godcc-list.a68
index 796fa33..849212b 100644
--- a/src/godcc-list.a68
+++ b/src/godcc-list.a68
@@ -24,7 +24,7 @@ begin
JSON_Val languages := ce_get_json ("languages");
json_foreach_elem (languages,
(ref JSON_Val v) void:
- puts (json_str (v->"id") + "\n"));
+ puts (json_str (v->"id") + "'n"));
ce_disconnect
end;
@@ -35,7 +35,7 @@ begin
ce_get_text (what,
(int e, n, fd) void:
begin (n > 0 | puts (fgets (fd, n)));
- (e = 0 | puts ("\n"))
+ (e = 0 | puts ("'n"))
end);
ce_disconnect
end;
@@ -47,7 +47,7 @@ begin
json_for_each_elem (f->"styles",
(ref JSON_Val style) void:
puts (" (" + json_str (style) + ")"));
- puts ("\n");
+ puts ("'n");
false
end;
diff --git a/src/godcc.a68 b/src/godcc.a68
index 2a87e40..b90692e 100644
--- a/src/godcc.a68
+++ b/src/godcc.a68
@@ -47,7 +47,7 @@ begin string godcc_version = "1.0";
(NOT be_quiet | puts (msg));
proc error = (string msg) void:
- begin puts ("godcc: error: " + msg + "\n");
+ begin puts ("godcc: error: " + msg + "'n");
set_exit_status (1);
stop
end;
@@ -76,49 +76,49 @@ begin string godcc_version = "1.0";
# --help and --version #
proc do_help = (string arg) bool:
- begin puts ("Usage: godcc [ARG...] list (languages | compilers [-l LANGUAGE] | formats)\n\
- or: godcc [ARG...] compile [-c COMPILER] [-o OUTFILE] [SRCFILE] [-- [CARG...]]\n\
- or: godcc [ARG...] format [-f FORMATTER] [-s STYLE] [-o OUTFILE] [SRCFILE]\n");
- puts ("Command-line front-end to Compiler Explorer.\n");
- puts ("\n");
- puts ("Arguments for list compilers:\n\
- -l, --language=LANGUAGE list compilers for the specified language\n\
- only.\n");
- puts ("\n");
- puts ("Arguments for compile:\n\
- SRCFILE source file. Defaults to -, the standard input.\n\
- -c, --compiler=COMPILER compiler to use.\n\
- -- [CARG...] options to send to compiler verbatim.\n");
- puts ("\n");
+ begin puts ("Usage: godcc [ARG...] list (languages | compilers [-l LANGUAGE] | formats)'n\
+ or: godcc [ARG...] compile [-c COMPILER] [-o OUTFILE] [SRCFILE] [-- [CARG...]]'n\
+ or: godcc [ARG...] format [-f FORMATTER] [-s STYLE] [-o OUTFILE] [SRCFILE]'n");
+ puts ("Command-line front-end to Compiler Explorer.'n");
+ puts ("'n");
+ puts ("Arguments for list compilers:'n\
+ -l, --language=LANGUAGE list compilers for the specified language'n\
+ only.'n");
+ puts ("'n");
+ puts ("Arguments for compile:'n\
+ SRCFILE source file. Defaults to -, the standard input.'n\
+ -c, --compiler=COMPILER compiler to use.'n\
+ -- [CARG...] options to send to compiler verbatim.'n");
+ puts ("'n");
puts ("\
- Note that if the program is invoked under a name like godcc-COMPILER\n\
- then COMPILER is the default for -c|--compiler.\n");
- puts ("\n");
- puts ("Arguments for format:\n\
- SRCFILE source file. Defaults to -, the standard input.\n\
- -f, --formatter=FORMATTER formatter to use. Defaults to clangformat.\n\
- -s, --style=STYLE style to use. Defaults to GNU.\n\
- -o output file. Defaults to -, the standard output.\n");
- puts ("\n");
- puts ("General arguments:\n\
- -q, --quiet be quiet. Useful for scripting\n\
- --help print a help message and exit.\n\
- --version show version and exit.\n");
- puts ("\n");
- puts ("Environment variables:\n\
- GODCC_CEHOST hostname where to connect to CE\n\
- GODCC_CEPORT port to use for connecting to CE\n");
- puts ("\n");
- puts ("Report bugs to: jemarch@gnu.org\n");
+ Note that if the program is invoked under a name like godcc-COMPILER'n\
+ then COMPILER is the default for -c|--compiler.'n");
+ puts ("'n");
+ puts ("Arguments for format:'n\
+ SRCFILE source file. Defaults to -, the standard input.'n\
+ -f, --formatter=FORMATTER formatter to use. Defaults to clangformat.'n\
+ -s, --style=STYLE style to use. Defaults to GNU.'n\
+ -o output file. Defaults to -, the standard output.'n");
+ puts ("'n");
+ puts ("General arguments:'n\
+ -q, --quiet be quiet. Useful for scripting'n\
+ --help print a help message and exit.'n\
+ --version show version and exit.'n");
+ puts ("'n");
+ puts ("Environment variables:'n\
+ GODCC_CEHOST hostname where to connect to CE'n\
+ GODCC_CEPORT port to use for connecting to CE'n");
+ puts ("'n");
+ puts ("Report bugs to: jemarch@gnu.org'n");
false
end;
proc do_version = (string arg) bool:
- begin puts ("godcc " + godcc_version + "\n\n");
- puts ("Copyright (C) 2025 Jose E. Marchesi.\n");
- puts ("License GPLv3+: GNU GPL version 3 or later.\n");
- puts ("This is free software: you are free to change and redistribute it.\n");
- puts ("There is NO WARRANTY, to the extent permitted by law.\n");
+ begin puts ("godcc " + godcc_version + "'n'n");
+ puts ("Copyright (C) 2025 Jose E. Marchesi.'n");
+ puts ("License GPLv3+: GNU GPL version 3 or later.'n");
+ puts ("This is free software: you are free to change and redistribute it.'n");
+ puts ("There is NO WARRANTY, to the extent permitted by law.'n");
false
end;
diff --git a/src/http.a68 b/src/http.a68
index a211ebe..cbab106 100644
--- a/src/http.a68
+++ b/src/http.a68
@@ -52,12 +52,12 @@ proc http_get = (string uri, []struct (string n, v) headers,
int socket, proc(int,int,int)void h,
bool fragmented) void:
begin # Prepare the header to send. #
- string msg := "GET " + uri + " HTTP/1.1\r\n";
+ string msg := "GET " + uri + " HTTP/1.1'r'n";
for i to UPB headers
do msg +:= (n of headers[i]) + ": " + (v of headers[i]);
- msg +:= "\r\n"
+ msg +:= "'r'n"
od;
- msg +:= "\r\n";
+ msg +:= "'r'n";
# Send it. #
fputs (socket, msg);
# Collect answer from server. #
@@ -89,13 +89,13 @@ proc http_post = (string uri, arg, []struct (string n, v) headers,
int socket, proc(int,int,int)void h,
bool fragmented) void:
begin # Prepare the header to send. #
- string msg := "POST " + uri + " HTTP/1.1\r\n";
+ string msg := "POST " + uri + " HTTP/1.1'r'n";
for i to UPB headers
do msg +:= (n of headers[i]) + ": " + (v of headers[i]);
- msg +:= "\r\n"
+ msg +:= "'r'n"
od;
- msg +:= "Content-Length: " + itoa (UPB arg) + "\r\n";
- msg +:= "\r\n";
+ msg +:= "Content-Length: " + itoa (UPB arg) + "'r'n";
+ msg +:= "'r'n";
msg +:= arg;
# Send it. #
fputs (socket, msg);
@@ -114,7 +114,7 @@ proc http_process_response = (int socket,
bool fragmented) void:
begin # First the header. #
int content_length, string line, bool read_chunks := false;
- while (line := fgets (socket, 0)) /= "\r\n"
+ while (line := fgets (socket, 0)) /= "'r'n"
do if UPB line >= 17 andth line[1:16] = "Content-Length: "
then content_length := atoi (line[17:], 10)
elif UPB line >= 26 andth line[1:26] = "Transfer-Encoding: chunked"
@@ -128,12 +128,12 @@ begin # First the header. #
do string line = fgets (socket, 0);
int size = atoi (line, 16);
h ((size = 0 | 0 | -1), size, socket);
- fgetc (socket); fgetc (socket); # \r\n #
+ fgetc (socket); fgetc (socket); # 'r'n #
(size = 0 | done := true)
od;
h (0, 0, socket)
else if content_length = 0
- then error ("couldn't find Content-Length header in response") fi;
+ then error ("couldn''t find Content-Length header in response") fi;
if fragmented
then # Call the handler to process the data in chunks.
Eighty is arbitrary, roughly a line size. #
@@ -162,12 +162,12 @@ begin string res, char sharp = REPR 35;
|: c = "{" | res +:= "%7b"
|: c = "}" | res +:= "%7d"
|: c = "|" | res +:= "%7c"
- |: c = "\\" | res +:= "%5c"
+ |: c = "\" | res +:= "%5c"
|: c = "^" | res +:= "%5e"
|: c = "~" | res +:= "%7e"
|: c = "[" | res +:= "%5b"
|: c = "]" | res +:= "%5d"
- |: c = "'" | res +:= "%60"
+ |: c = "''" | res +:= "%60"
|: c = ";" | res +:= "%3b"
|: c = "/" | res +:= "%2f"
|: c = "?" | res +:= "%3f"
diff --git a/src/json.a68 b/src/json.a68
index 6c73ec4..04ea670 100644
--- a/src/json.a68
+++ b/src/json.a68
@@ -156,14 +156,14 @@ begin
for i to UPB s
do char c = s[i];
if getchar = eof orel ch /= c
- then parse_error ("expected '" + c + "'")
+ then parse_error ("expected ''" + c + "''")
fi
od;
proc parse_error = (string msg) void:
if ch = eof
then json_error (msg + ", found end of file")
- else json_error (msg + ", found '" + ch + "'")
+ else json_error (msg + ", found ''" + ch + "''")
fi;
# Parse a single JSON value. #
@@ -183,14 +183,15 @@ begin
begin string res;
while getchar /= """"
do if ch = eof then json_error ("while parsing string")
- elif ch = "\\"
+ elif ch = "\"
then ch = getchar;
+
if ch = eof then json_error ("unterminated string escape")
- elif ch = "n" then res +:= "\n"
- elif ch = "t" then res +:= "\t"
+ elif ch = "n" then res +:= "'n"
+ elif ch = "t" then res +:= "'t"
elif ch = """" then res +:= """"
- elif ch = "\\" then res +:= ch
- else json_error ("invalid string escape \\" + ch)
+ elif ch = "\" then res +:= ch
+ else json_error ("invalid string escape \" + ch)
fi
else res +:= ch
fi
@@ -281,9 +282,9 @@ proc json_escape_string = (string str) string:
begin string res;
for i to UPB str
do char newline = REPR 10, tab = REPR 9, c = str[i];
- (c = "\\" | res +:= "\\\\"
- |: c = newline | res +:= "\\n"
- |: c = tab | res +:= "\\t"
+ (c = "\" | res +:= "\\"
+ |: c = newline | res +:= "\n"
+ |: c = tab | res +:= "\t"
| res +:= c)
od;
res
--
2.30.2
More information about the Algol68
mailing list