delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/07/12/20:13:50

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:date:message-id:subject:from:to:content-type;
bh=UIrBBKJRvKOQ/ME1WNtaPyKCDvD1HsSoZ2zXi5Vq2qQ=;
b=S+K2AZGeeHf+P+Befqq1ar8E0ErXNjJoIK63EWV1rnvY9OxP8vJGgzRfX3NoSY1ZmO
9nKNJhLJfD+WMYCR22De2gFUL1cyFVLPXDCLTIxuFsEXFeSd4R+yWbhlYZHp/8Grvgus
QQLaJ3XNVuwFlRks2EAX5UUXw01BJjje/WN76G1sdMO+pDkqk1otOz/boP0BEd30wiYN
4DmiutCeVGza5NM7JWKD4lGvHw0X3jjA/b4dNGe5s0hSxd6+At0icrMJgUQ9GOyoGX+8
/xAp+Pkj8nD2JbTzwgu9sZyX4tFywNwcM/G5gQZ/L6h0E+TyZkRXWX3VcB+1MrHrsnj3
SzjA==
MIME-Version: 1.0
Date: Thu, 12 Jul 2012 18:42:49 -0500
Message-ID: <CAA-ihx9exryc-z2z30W3E+WsJG_rERTKjrMbE9D6=WbAvyrf-Q@mail.gmail.com>
Subject: mktemp() fails on "detmp.xxx" but not "detmp.XXX" (proposed patch)
From: Rugxulo <rugxulo AT gmail DOT com>
To: djgpp-workers AT delorie DOT com
Reply-To: djgpp-workers AT delorie DOT com

Hey guys,

From the recent discussion about the tiny M-! bug in DJGPP Emacs, it
seems mktemp.c requires template filenames to have capital 'X' in
them, so it fails on lowercase 'x'. Personally, I consider that a bug,
but who knows, maybe that's intentional (or at least moreso for POSIX
file systems).

Okay, so PuppyLinux here (using glibc's mktemp) does indeed fail on
"detmp.xxx" as well as "detmp.XXX" though "detmpXXXXXX" works. I'd say
we don't have to mimic that too closely. I know this can be avoided by
always having uppercase (or at least not downcasing the filename), but
that's too irregular for my tastes and is too easy to trip over, IMHO.

http://www.delorie.com/bin/cvsweb.cgi/djgpp/src/libc/compat/stdio/mktemp.c

Seems it hasn't been updated since 2000 (except for adding "#include
<stdlib.h>"). Hence this applies to both 2.03p2 "current" and 2.04
"beta".

My proposed patch would "#include <ctype.h>" and change ...

while (xcount < 6 && cp > _template && cp[-1] == 'X')

... to this ...

while (xcount < 6 && cp > _template && toupper(cp[-1]) == 'X')

Recompiling mktemp.c with -DTEST seems to show it works okay. I know
this isn't a top tier problem or anything, but it sure is a strange
thing to fail at, very arbitrary, IMHO. So better handling would be
nice, I think.

Feel free to comment (or ignore).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019