On Sat, 27 Jan 2007 02:22:58 -0500 Shawn O. Pearce wrote:[...] No, this is broken - backslashes cannot be used to quote special characters in braces. If the first character of a word is an open brace (``{'') then the word is terminated by the matching close brace (``}''). Braces nest within the word: for each additional open brace there must be an additional close brace (however, if an open brace or close brace within the word is quoted with a backslash then it is not counted in locating the matching close brace). No substitutions are performed on the characters between the braces except for backslash-newline substitutions described below, nor do semi-colons, newlines, close brackets, or white space receive any special interpretation. The word will consist of exactly the characters between the outer braces, not includ- ing the braces themselves. The problem is that using '\{' will protect from nonmatching braces, but the backslash will stay in the resulting string - it will not be removed. Similarly for '\}' and '\\'. Tcl itself checks whether using braces is safe (it could be safe if the text does not have nonmatching braces and does not have an odd number of backslash characters at end of line), and uses just backslashes if braces cannot be used. See tclUtil.c, Tcl_ScanCountedElement() and Tcl_ConvertCountedElement(). This code adds a backslash before ']', '[', '$', ';', ' ', '\\', '"', '{', '}', and also converts special characters '\f', '\n', '\r', '\t', '\v' to C-style escape sequences. Untested code (output will not look very nice, but it is not intended for human consumption anyway): void tcl_quote_print(FILE *stream, const char *src) { char c; while ((c = *src++)) { switch (c) { case ']': case '[': case '$': case ';': case ' ': case '\\': case '"': case '{': case '}': fputc('\\', stream); default: fputc(c, stream); break; case '\f': fputs("\\f", stream); break; case '\n': fputs("\\n", stream); break; case '\r': fputs("\\r", stream); break; case '\t': fputs("\\t", stream); break; case '\v': fputs("\\v", stream); break; } } }
| Oleg Nesterov | Re: [PATCH, RFC] reimplement flush_workqueue() |
| Linus Torvalds | Re: Linux 2.6.27-rc8 |
| Pavel Roskin | ndiswrapper and GPL-only symbols redux |
| Greg Kroah-Hartman | [PATCH 017/196] aoechr: Convert from class_device to device |
git: | |
| David Symonds | Re: git and binary files |
| Matthieu Moy | git push to a non-bare repository |
| Felipe Oliveira Carvalho | Re: [RFC] Zit: the git-based single file content tracker |
| Jakub Narebski | Re: [VOTE] git versus mercurial (for DragonflyBSD) |
| Patrick McHardy | netfilter 05/29: netns ebtables: part 2 |
| Templin, Fred L | [Resend][PATCH 01/05] ipv6: RFC4214 Support (4) |
| Laszlo Attila Toth | [PATCHv7 0/5 + 3] Interface group patches |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Han Boetes | shutdown gets stuck at `syncing discs...' |
| Leon Dippenaar | New tcp stack attack |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
