tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] How to use char "\"


From: Charles Gordon
Subject: Re: [Tinycc-devel] How to use char "\"
Date: Tue, 30 Sep 2014 23:12:57 +0200

On 30 sept. 2014, at 18:46, Daniel Glöckner <address@hidden> wrote:

> Hi,
> 
> On Wed, Oct 01, 2014 at 12:06:24AM +0800, Thomas Preud'homme wrote:
>>> I have a problem with the char "\". For example in the line:
>>> 
>>>    strpbrk (file_name,"\*?")
>>> 
>>> ir order to know if i have a simple file name, tcc tells me "unknown
>>> escape sequence".
>> 
>> The manpage doesn't say that the strings accept escape sequence. Is it even 
>> defined in the standard? Sounds like a bug in TinyCC.
> 
> Thomas, C does support the escape sequences \a, \b, \f, \n, \r, \t,
> \v, \', \", \?, \\, \<3octal>, \x<2hex>, \u<4hex>, and \U<8hex>.

More precisely, and contrary to popular belief, \x<at least one isxdigit char>. 
 Standard C specifies this.
“\023” is a string with only one character.

> I guess BCC probably interpreted \* as \\*.

BCC should interpret “\*” as “*”, otherwise it is a non standard behavior.
The code fragment probably attempts to catch forbidden characters in file_name.
\ is the ominous path separator in the MSDOS/Windows world (/ can be used as 
well in Windows and in MSDOS)
The correct string for this should have been “\\*?"
To port this code to unix, you should change the string to “/*?”
and to make it somewhat more portable, you might want to change it to “/\\*?”
But this code is obsolete anyway: note that the restriction on * and ? in 
filenames does not exist in most unix file systems, nor probably in Windows and 
Mac modern file systems.
wildcard expansion is actually a feature of the command line interpreter (aka 
shell), and of some very specific file searching APIs in Windows.

Chqrlie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]