Hi!

23-Июл-2005 05:34 [EMAIL PROTECTED] (Kenneth J. Davis) wrote to
[email protected]:

>>     if (rest [1] != ':' || rest [2] != '\0')
>> KD> +    drive = toupper(rest[0]) - 'A';
>>      Here not checked, that rest [0] is a letter.
KJD> true, but according to TC docs, toupper() supports EOF (-1 I believe) to
KJD>   255 and any non-lowercase item is returned unchanged; so no check

     No, I mean something like:

if (!isletter (rest [0]) || rest [1] != ':' || rest [2] != '\0')
>---^^^^^^^^^^^^^^^^^^^^^^^

KJD> should be necessary.  I suppose we could explicitly check for a letter
KJD> argument and return syntax error if not (since not a drive usually),
KJD> then change to use _toupper macro or even straight bit manipulation
KJD> (anding off bit 5 I think).

______________O\_/_________________________________\_/O______________
/* !!! Fast ASCII tolower/toupper !!! */
#define _lower(ch)      ((ch) | 0x20)
#define _dolower(var)   ((var) |= 0x20)
#define _upper(ch)      ((ch) & ~0x20)
#define _doupper(var)   ((var) &= ~0x20)
_____________________________________________________________________
              O/~\                                 /~\O

Thus:

char ch = rest [0]; _doupper (ch);
if (ch < 'A' || ch > 'Z') ...not a letter...

PS: Just to remember how to fast upper/lowercase: in 16x16 ASCII table first
two columns (0x00-0x1F) are control codes, two second columns (0x20-0x3F) -
punctuations, next two columns (0x40-0x5F) of upcase and then two columns
(0x60-0x7F) of lowercase. Thus, clearing bit 0x20, is required and enough to
convert lower case into upcase, remain upcase in upcase. All other codes not
fall into letters.




-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to