Re: Signature
"John E. Davis" <[email protected]>
| Newsgroups | gmane.network.slrn.user |
|---|---|
| Message-ID | <[email protected]> |
Ivan Popovski <[email protected]> wrote: > Ok dont be cruel, this is my first slang script, and I didnt have time > to polish it (exams atm). If you find error pls let me know :) Congratulations on your first slang script. The only problem that I see is that you have not dealt with the return values of pclose and fclose. Here is a version that remedies this. Good luck, --John define random_sig () { variable str, buf; variable signature_file = get_variable_value ("signature"); variable matched, pos, len; % matched = string_match(signature_file, "\\([a-z]+\\)\\(\|\\)", 1); matched = string_match(signature_file, "^\\(.+\\)\\(\|\\)$", 1); if (matched == 0) return; (pos, len) = string_match_nth(2); if (pos) { variable pd = NULL, fp = NULL; EXIT_BLOCK { if (pd != NULL) () = pclose (pd); if (fd != NULL) () = fclose (fp); } set_string_variable("signature", ".sigtmp"); str = strtrans (signature_file, "|", ""); pd = popen (str,"r"); if (pd == NULL) return; fd=fopen(".sigtmp","w"); if (fd == NULL) return; while (-1 != fgets (&buf, pd)) { if ((-1 == fputs (buf, fd))) return; } } } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/