delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/12/14:25:23

From: "Yogesh Sharma" <SHARMAYOGESH AT prodigy DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Changes to getenv.c
Date: Sat, 12 Jun 1999 13:25:35 -0400
Organization: Prodigy Internet http://www.prodigy.com
Lines: 45
Message-ID: <7ju5dv$3bk2$1@newssvr01-int.news.prodigy.com>
NNTP-Posting-Host: lnsgb102-20.splitrock.net
X-Trace: newssvr01-int.news.prodigy.com 929208575 3623747 209.156.127.20 (12 Jun 1999 17:29:35 GMT)
X-Complaints-To: abuse AT prodigy DOT net
NNTP-Posting-Date: 12 Jun 1999 17:29:35 GMT
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MSMail-Priority: Normal
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Below is the source for getenv.c. I am planning to change the following line
:
    while (*ep && *np && *ep == *np && *np != '=')

To
    while (*ep && *np && toupper(*ep) == toupper(*np) && *np != '=')

Reason for changing this

DOS is not a case sensitive OS, so why don't we convert the environment
variable and search variable to upper case so that the users may not have
any problem regarding the case.

Thanks



/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
#include <string.h>

extern char **environ;

char *
getenv(const char *name)
{
  int i;

  if (environ == 0)
    return 0;

  for (i=0; environ[i]; i++)
  {
    char *ep = environ[i];
    const char *np = name;
    while (*ep && *np && *ep == *np && *np != '=')
      ep++, np++;
    if (*ep == '=' && *np == 0)
      return ep+1;
  }
  return 0;
}



- Raw text -


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