[hackers] [PATCH] proxy-uri -> proxy-resolver for no_proxy
--- surf.1 | 7 +++ surf.c | 15 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/surf.1 b/surf.1 index c1d339a..1715f93 100644 --- a/surf.1 +++ b/surf.1 @@ -283,6 +283,13 @@ string .TP .B http_proxy If this variable is set and not empty upon startup, surf will use it as the http proxy +.TP +.B no_proxy +If both http_proxy is set and no_proxy contain a +.BR comma-separated +list of domain extensions and both is not empty upon startup, proxy will +.BR not +be used for each of the elements in no_proxy. .SH PLUGINS For using plugins in surf, first determine your running architecture. Then get the appropriate plugin for that architecture and copy it to diff --git a/surf.c b/surf.c index ea0e260..fdfaab1 100644 --- a/surf.c +++ b/surf.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "arg.h" @@ -1290,9 +1291,9 @@ void setup(void) { int i; - char *proxy, *new_proxy; + char *proxy, *new_proxy, *no_proxy, **new_no_proxy; char *styledirfile, *stylepath; - SoupURI *puri; + GProxyResolver *pr; SoupSession *s; GError *error = NULL; @@ -1367,15 +1368,19 @@ setup(void) /* proxy */ if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { new_proxy = g_strrstr(proxy, "http://";) + || g_strrstr(proxy, "https://";) || g_strrstr(proxy, "socks://") || g_strrstr(proxy, "socks4://") + || g_strrstr(proxy, "socks4a://") || g_strrstr(proxy, "socks5://") ? g_strdup(proxy) : g_strdup_printf("http://%s";, proxy); - puri = soup_uri_new(new_proxy); - g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); - soup_uri_free(puri); + new_no_proxy = ((no_proxy = getenv("no_proxy")) && strcmp(no_proxy, "")) + ? g_strsplit(no_proxy, ",", -1) : NULL; + pr = g_simple_proxy_resolver_new(new_proxy, new_no_proxy); + g_object_set(G_OBJECT(s), "proxy-resolver", pr, NULL); g_free(new_proxy); + g_free(new_no_proxy); usingproxy = 1; } } -- 2.6.4
[hackers] [PATCH] proxy-uri -> proxy-resolver for no_proxy
--- surf.1 | 7 +++ surf.c | 15 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/surf.1 b/surf.1 index c1d339a..1715f93 100644 --- a/surf.1 +++ b/surf.1 @@ -283,6 +283,13 @@ string .TP .B http_proxy If this variable is set and not empty upon startup, surf will use it as the http proxy +.TP +.B no_proxy +If both http_proxy is set and no_proxy contain a +.BR comma-separated +list of domain extensions and both is not empty upon startup, proxy will +.BR not +be used for each of the elements in no_proxy. .SH PLUGINS For using plugins in surf, first determine your running architecture. Then get the appropriate plugin for that architecture and copy it to diff --git a/surf.c b/surf.c index ea0e260..fdfaab1 100644 --- a/surf.c +++ b/surf.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "arg.h" @@ -1290,9 +1291,9 @@ void setup(void) { int i; - char *proxy, *new_proxy; + char *proxy, *new_proxy, *no_proxy, **new_no_proxy; char *styledirfile, *stylepath; - SoupURI *puri; + GProxyResolver *pr; SoupSession *s; GError *error = NULL; @@ -1367,15 +1368,19 @@ setup(void) /* proxy */ if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { new_proxy = g_strrstr(proxy, "http://";) + || g_strrstr(proxy, "https://";) || g_strrstr(proxy, "socks://") || g_strrstr(proxy, "socks4://") + || g_strrstr(proxy, "socks4a://") || g_strrstr(proxy, "socks5://") ? g_strdup(proxy) : g_strdup_printf("http://%s";, proxy); - puri = soup_uri_new(new_proxy); - g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL); - soup_uri_free(puri); + new_no_proxy = ((no_proxy = getenv("no_proxy")) && strcmp(no_proxy, "")) + ? g_strsplit(no_proxy, ",", -1) : NULL; + pr = g_simple_proxy_resolver_new(new_proxy, new_no_proxy); + g_object_set(G_OBJECT(s), "proxy-resolver", pr, NULL); g_free(new_proxy); + g_free(new_no_proxy); usingproxy = 1; } } -- 2.6.4
[hackers] [sbase] Move edit logic to an individual function || Roberto E. Vargas Caballero
commit 6135cad495e562b0d3108942ca8de2b285699e0e Author: Roberto E. Vargas Caballero AuthorDate: Wed Dec 16 21:21:55 2015 +0100 Commit: sin CommitDate: Wed Dec 16 20:25:50 2015 + Move edit logic to an individual function It is better to separate this logic from the parameter logic in main(). diff --git a/ed.c b/ed.c index 3d90d4d..a3de436 100644 --- a/ed.c +++ b/ed.c @@ -1343,6 +1343,22 @@ sighup(int dummy) quit(); } +static void +edit(void) +{ + setjmp(savesp); + for (;;) { + newcmd = 1; + ocurln = curln; + cmdsiz = 0; + repidx = -1; + if (optprompt) + fputs(prompt, stdout); + getlst(); + chkglobal() ? doglobal() : docmd(); + } +} + int main(int argc, char *argv[]) { @@ -1373,16 +1389,7 @@ main(int argc, char *argv[]) } } - for (;;) { - newcmd = 1; - ocurln = curln; - cmdsiz = 0; - repidx = -1; - if (optprompt) - fputs(prompt, stdout); - getlst(); - chkglobal() ? doglobal() : docmd(); - } + edit(); /* not reached */ return 0;
[hackers] [sbase] Fix small typo in comment || Roberto E. Vargas Caballero
commit 05af2156b6259ca8efc1674bc9d572a912bdba62 Author: Roberto E. Vargas Caballero AuthorDate: Wed Dec 16 21:17:52 2015 +0100 Commit: sin CommitDate: Wed Dec 16 20:25:50 2015 + Fix small typo in comment diff --git a/ed.c b/ed.c index c060e5f..3d90d4d 100644 --- a/ed.c +++ b/ed.c @@ -1304,7 +1304,7 @@ doglobal(void) } docmd(); } - discard(); /* cover the case of not matchingc anything */ + discard(); /* cover the case of not matching anything */ } static void
[hackers] [sbase] Escape correctly characters in getrhs() || Roberto E. Vargas Caballero
commit 3e130cee6698c3c3f95468a7b8a4e782ea474338 Author: Roberto E. Vargas Caballero AuthorDate: Wed Dec 16 19:44:44 2015 +0100 Commit: sin CommitDate: Wed Dec 16 20:16:12 2015 + Escape correctly characters in getrhs() getrhs() must remove \ excepts in the case of & and \d (where d is a digit), because in this case are sequences understood by addsub(), so addsub() must be able to see them. diff --git a/ed.c b/ed.c index 9a80eb9..33b4837 100644 --- a/ed.c +++ b/ed.c @@ -890,6 +890,10 @@ getrhs(int delim) s = NULL; siz = cap = 0; while ((c = input()) != '\n' && c != EOF && c != delim) { + if (c == '\\') { + if ((c = input()) == '&' || isdigit(c)) + s = addchar(c, s, &siz, &cap); + } s = addchar(c, s, &siz, &cap); } s = addchar('\0', s, &siz, &cap);
[hackers] [sbase] Discard input at the end of global commands || Roberto E. Vargas Caballero
commit a65e180e5e5eca77ca13de082f3e16c0402b18af Author: Roberto E. Vargas Caballero AuthorDate: Wed Dec 16 19:39:21 2015 +0100 Commit: sin CommitDate: Wed Dec 16 20:16:12 2015 + Discard input at the end of global commands If there is no any match, then the rest of the line is not read, and it means that ed thins it is a new command. diff --git a/ed.c b/ed.c index bde2c55..9a80eb9 100644 --- a/ed.c +++ b/ed.c @@ -65,28 +65,35 @@ static struct undo udata; static int newcmd; -static void undo(void); static void -error(char *msg) +discard(void) { int c; + /* discard until end of line */ + if (repidx < 0 && + ((cmdsiz > 0 && cmdline[cmdsiz-1] != '\n') || cmdsiz == 0)) { + while ((c = getchar()) != '\n' && c != EOF) + /* nothing */; + } +} + +static void undo(void); + +static void +error(char *msg) +{ exstatus = 1; lasterr = msg; fputs("?\n", stderr); if (optverbose) fprintf(stderr, "%s\n", msg); - - /* discard until end of line */ - if (repidx < 0 && cmdsiz > 0 && cmdline[cmdsiz-1] != '\n') { - while ((c = getchar()) != '\n' && c != EOF) - /* nothing */; - } - if (!newcmd) undo(); + + discard(); curln = ocurln; longjmp(savesp, 1); } @@ -1293,6 +1300,7 @@ doglobal(void) } docmd(); } + discard(); /* cover the case of not matchingc anything */ } static void
[hackers] [sbase] call to addpre() in every iteration of subline() || Roberto E. Vargas Caballero
commit 694a5ef7fbca54581a431a528972509c5a2e8bc0 Author: Roberto E. Vargas Caballero AuthorDate: Wed Dec 16 20:18:09 2015 +0100 Commit: sin CommitDate: Wed Dec 16 20:16:12 2015 + call to addpre() in every iteration of subline() It is needed to call to addpre(), because in other case the prefix of all the occurrences before the target will not be copied to the result string. diff --git a/ed.c b/ed.c index 33b4837..c060e5f 100644 --- a/ed.c +++ b/ed.c @@ -991,10 +991,10 @@ subline(int num, int nth) siz = 0; for (m = match(num); m; m = rematch(num)) { + addpre(&s, &cap, &siz); if (--nth > 0) continue; changed = 1; - addpre(&s, &cap, &siz); addsub(&s, &cap, &siz); if (nth == 0) break;
Re: [hackers][sbase][PATCH] Activate the "else if" branch
Heyho On Wed, Dec 16, 2015 at 9:28 AM, Roberto E. Vargas Caballero wrote: > On Tue, Dec 15, 2015 at 07:54:28PM +0100, Silvan Jegen wrote: >> We checked the same condition in the "if" branch so it was never true >> in the "else if" one. Removing this condition makes the "else if" >> branch viable. > > I'm sorry, but you are wrong here. Setjmp saves the current state No need to be sorry I am wrong all the time :P > of the program, and it allows that a deeper call to longjmp restores > the state. When setjmp is called directly it returns always 0, > but when it returns dur to a call to longjmp it returns a value > passed as parameter to longjmp (in our case 1). It is a kind of > try {} catch{} ala C. > >> dowrite("ed.hup", 1); >> - } else if (home && !setjmp(savesp)) { >> + } else if (home) { >> n = snprintf(fname, > > If you remove the setjmp in the else if branch, then any call > to error (which calls to longjmp) will resume the execution in > the if branch, making a new execution of the else if branch, > which in some cases will produce an infinite loop. That means that the "else if" clause should only run when setjmp returns directly and not due to a call to longjmp. I wasn't considering the side effects of calling setjmp so ignore this patch. Thanks for the feedback! Cheers, Silvan
[hackers] [sbase] ed: use arg.h || Quentin Rameau
commit d1bef890ea45a8aa492d0a1914c02110f982da28 Author: Quentin Rameau AuthorDate: Tue Dec 15 15:45:16 2015 +0100 Commit: sin CommitDate: Wed Dec 16 09:52:35 2015 + ed: use arg.h diff --git a/ed.c b/ed.c index 032bc78..bde2c55 100644 --- a/ed.c +++ b/ed.c @@ -13,6 +13,8 @@ #include #include +#include "arg.h" + #define REGEXSIZE 100 #define LINESIZE80 #define NUMLINES32 @@ -1332,27 +1334,20 @@ sighup(int dummy) int main(int argc, char *argv[]) { - char *p; + ARGBEGIN { + case 'p': + prompt = EARGF(usage()); + optprompt = 1; + break; + case 's': + optdiag = 0; + break; + default: + usage(); + } ARGEND - while (*++argv) { - if (argv[0][0] != '-') - break; - for (p = argv[0] + 1; *p; ++p) { - switch (*p) { - case 's': - optdiag = 0; - break; - case 'p': - if (!*++argv) - usage(); - prompt = *argv; - optprompt = 1; - break; - default: - usage(); - } - } - } + if (argc > 1) + usage(); signal(SIGINT, sigintr); signal(SIGHUP, sighup);
[hackers] [sbase] ed: fix cmd e/E || Quentin Rameau
commit c5b36e17600920ac1a5d519620be5b38f8f9ed39 Author: Quentin Rameau AuthorDate: Tue Dec 15 15:13:21 2015 +0100 Commit: sin CommitDate: Wed Dec 16 09:52:35 2015 + ed: fix cmd e/E Ensure we have a filename before taking further action. diff --git a/ed.c b/ed.c index 3f878eb..032bc78 100644 --- a/ed.c +++ b/ed.c @@ -1191,8 +1191,8 @@ repeat: goto unexpected; if (modflag) goto modified; - setscratch(); strcpy(savfname, getfname()); + setscratch(); deflines(curln, curln); doread(savfname); clearundo();
Re: [hackers][sbase][PATCH] Activate the "else if" branch
On Tue, Dec 15, 2015 at 07:54:28PM +0100, Silvan Jegen wrote: > We checked the same condition in the "if" branch so it was never true > in the "else if" one. Removing this condition makes the "else if" > branch viable. I'm sorry, but you are wrong here. Setjmp saves the current state of the program, and it allows that a deeper call to longjmp restores the state. When setjmp is called directly it returns always 0, but when it returns dur to a call to longjmp it returns a value passed as parameter to longjmp (in our case 1). It is a kind of try {} catch{} ala C. > dowrite("ed.hup", 1); > - } else if (home && !setjmp(savesp)) { > + } else if (home) { > n = snprintf(fname, If you remove the setjmp in the else if branch, then any call to error (which calls to longjmp) will resume the execution in the if branch, making a new execution of the else if branch, which in some cases will produce an infinite loop. Regards,