Commit 283fcb0c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

replaced strncpy/strncmp by memcpy/memcmp

parent 1cc2e835
......@@ -8,6 +8,7 @@
* gridInqXinc: bug fix
* grid_check_cyclic: support for curvilinear grids without bounds
* streamOpenAppen: set ncmode to 2 (bug fix)
* replaced strncpy/strncmp by memcpy/memcmp
* Version 1.3.1 released
2009-01-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -42,7 +42,7 @@ void cdf_create(const char *path, int cmode, int *ncidp)
strcpy(basename, "./");
else
{
strncpy(basename, path, pend-path);
memcpy(basename, path, pend-path);
basename[pend-path] = 0;
}
......@@ -85,7 +85,7 @@ int cdf_open(const char *path, int omode, int *ncidp)
size_t chunksizehint = 0;
#if defined (HAVE_LIBNC_DAP)
if ( strncmp(path, "http:", 5) == 0 ) dapfile = TRUE;
if ( memcmp(path, "http:", 5) == 0 ) dapfile = TRUE;
#endif
if ( dapfile )
......
......@@ -320,7 +320,7 @@ static int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
len = strlen(file);
if ( len > MAXNAME-1 ) len = MAXNAME-1;
(void) strncpy(memTable[memID].file, file, len);
(void) memcpy(memTable[memID].file, file, len);
memTable[memID].file[len] = '\0';
}
else
......@@ -333,7 +333,7 @@ static int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
len = strlen(caller);
if ( len > MAXNAME-1 ) len = MAXNAME-1;
(void) strncpy(memTable[memID].caller, caller, len);
(void) memcpy(memTable[memID].caller, caller, len);
memTable[memID].caller[len] = '\0';
}
else
......@@ -388,7 +388,7 @@ static int memListChangeEntry(void *ptrold, void *ptr, size_t size,
len = strlen(file);
if ( len > MAXNAME-1 ) len = MAXNAME-1;
(void) strncpy(memTable[memID].file, file, len);
(void) memcpy(memTable[memID].file, file, len);
memTable[memID].file[len] = '\0';
}
else
......@@ -401,7 +401,7 @@ static int memListChangeEntry(void *ptrold, void *ptr, size_t size,
len = strlen(caller);
if ( len > MAXNAME-1 ) len = MAXNAME-1;
(void) strncpy(memTable[memID].caller, caller, len);
(void) memcpy(memTable[memID].caller, caller, len);
memTable[memID].caller[len] = '\0';
}
else
......
/* Automatically generated by m214003 at 2009-03-11, do not edit */
/* Automatically generated by m214003 at 2009-03-12, do not edit */
/* GRIBLIB_VERSION="1.3.0" */
......@@ -5028,7 +5028,7 @@ int gribCheckFiletype(int fileID)
if ( fileRead(fileID, buffer, 4) != 4 ) return(found);
if ( strncmp(buffer, "GRIB", 4) == 0 )
if ( memcmp(buffer, "GRIB", 4) == 0 )
{
found = 1;
if ( GRB_Debug ) Message(func, "found GRIB file = %s", fileInqName(fileID));
......@@ -8380,7 +8380,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return (gribLen);
}
static const char grb_libvers[] = "1.3.0" " of ""Mar 11 2009"" ""12:04:04";
static const char grb_libvers[] = "1.3.0" " of ""Mar 12 2009"" ""12:07:20";
const char *
gribLibraryVersion(void)
{
......
......@@ -137,7 +137,7 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
if ( instituts[instID].name )
{
len = strlen(instituts[instID].name);
if ( strncmp(instituts[instID].name, name, len) == 0 ) break;
if ( memcmp(instituts[instID].name, name, len) == 0 ) break;
}
}
}
......@@ -146,7 +146,7 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
if ( instituts[instID].longname )
{
len = strlen(instituts[instID].longname);
if ( strncmp(instituts[instID].longname, longname, len) == 0 ) break;
if ( memcmp(instituts[instID].longname, longname, len) == 0 ) break;
}
}
else
......
......@@ -148,11 +148,11 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
linelen -= 1;
functype = ISVOID;
funcargc = 0;
if ( strncmp(line, "int", 3) == 0 ||
strncmp(line, "void", 4) == 0 ||
strncmp(line, "char", 4) == 0 ||
strncmp(line, "const", 5) == 0 ||
strncmp(line, "double", 6) == 0 )
if ( memcmp(line, "int", 3) == 0 ||
memcmp(line, "void", 4) == 0 ||
memcmp(line, "char", 4) == 0 ||
memcmp(line, "const", 5) == 0 ||
memcmp(line, "double", 6) == 0 )
{
/* printf("%s\n", line); */
ii = 0;
......@@ -165,32 +165,32 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
line[ii] = 0;
/* printf("%s\n", line); */
pline = line;
if ( strncmp(line, "int", 3) == 0 )
if ( memcmp(line, "int", 3) == 0 )
{
functype = ISINT;
pline += 3;
}
else if ( strncmp(line, "void", 4) == 0 )
else if ( memcmp(line, "void", 4) == 0 )
{
functype = ISVOID;
pline += 4;
}
else if ( strncmp(line, "double*", 7) == 0 )
else if ( memcmp(line, "double*", 7) == 0 )
{
printf("skip: line %3d double *\n", lineno);
continue;
}
else if ( strncmp(line, "double", 6) == 0 )
else if ( memcmp(line, "double", 6) == 0 )
{
functype = ISDOUBLE;
pline += 6;
}
else if ( strncmp(line, "char*", 5) == 0 )
else if ( memcmp(line, "char*", 5) == 0 )
{
functype = ISCONSTSTRING;
pline += 5;
}
else if ( strncmp(line, "constchar*", 10) == 0 )
else if ( memcmp(line, "constchar*", 10) == 0 )
{
functype = ISCONSTSTRING;
pline += 10;
......@@ -203,7 +203,7 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
len = 0;
while ( isalnum((int) pline[len]) ) len++;
strncpy(funcname, pline, len);
memcpy(funcname, pline, len);
funcname[len] = 0;
/* printf("%s\n", funcname);*/
pline += len;
......@@ -237,46 +237,46 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
for ( i = 0; i < funcargc; i++ )
{
pline = funcargname[i];
if ( strncmp(pline, "const", 5) == 0 &&
strncmp(pline, "constchar*", 10) != 0 ) pline += 5;
if ( memcmp(pline, "const", 5) == 0 &&
memcmp(pline, "constchar*", 10) != 0 ) pline += 5;
if ( strncmp(pline, "void", 4) == 0 )
if ( memcmp(pline, "void", 4) == 0 )
{
pline += 4;
funcargtype[i] = ISVOID;
funcargname[i] = pline;
}
else if ( strncmp(pline, "constchar*", 10) == 0 )
else if ( memcmp(pline, "constchar*", 10) == 0 )
{
pline += 10;
funcargtype[i] = ISSTRING;
funcargname[i] = pline;
}
else if ( strncmp(pline, "char*", 5) == 0 )
else if ( memcmp(pline, "char*", 5) == 0 )
{
pline += 5;
funcargtype[i] = ISSTRINGP;
funcargname[i] = pline;
}
else if ( strncmp(pline, "int*", 4) == 0 )
else if ( memcmp(pline, "int*", 4) == 0 )
{
pline += 4;
funcargtype[i] = ISINTP;
funcargname[i] = pline;
}
else if ( strncmp(pline, "int", 3) == 0 )
else if ( memcmp(pline, "int", 3) == 0 )
{
pline += 3;
funcargtype[i] = ISINT;
funcargname[i] = pline;
}
else if ( strncmp(pline, "double*", 7) == 0 )
else if ( memcmp(pline, "double*", 7) == 0 )
{
pline += 7;
funcargtype[i] = ISDOUBLEP;
funcargname[i] = pline;
}
else if ( strncmp(pline, "double", 6) == 0 )
else if ( memcmp(pline, "double", 6) == 0 )
{
pline += 6;
funcargtype[i] = ISDOUBLE;
......@@ -419,7 +419,7 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
nfdoc++;
}
}
else if ( strncmp(line, "#define", 7) == 0 )
else if ( memcmp(line, "#define", 7) == 0 )
{
pline = line;
pline += 7;
......@@ -442,7 +442,7 @@ void fortran_interface(char *fname, char *fnameinc, char *fnameint)
fprintf(fpinc, " INTEGER %-22s\n", parname);
fprintf(fpinc, " PARAMETER (%-22s = %2d)\n", parname, parvalue);
}
else if ( strncmp(line, "/*", 2) == 0 )
else if ( memcmp(line, "/*", 2) == 0 )
{
int dpos = 0;
pline = line;
......@@ -573,8 +573,8 @@ int main(int argc, char *argv[])
if ( cp == NULL ) len = strlen(fname);
else len = cp - fname;
strncpy(fnameinc, fname, len);
strncpy(fnameint, fname, len);
memcpy(fnameinc, fname, len);
memcpy(fnameint, fname, len);
strcpy(fnameinc+len, ".inc");
strcpy(fnameint+len, "Fortran.c");
......
......@@ -311,9 +311,9 @@ int modelInq(int instID, int modelgribID, char *name)
if ( modelptr->name )
{
len = strlen(modelptr->name);
if ( strncmp(modelptr->name, name, len) == 0 ) break;
if ( memcmp(modelptr->name, name, len) == 0 ) break;
len = strlen(name);
if ( strncmp(modelptr->name, name, len) == 0 ) break;
if ( memcmp(modelptr->name, name, len) == 0 ) break;
}
}
}
......
......@@ -112,7 +112,7 @@ static int getFiletype(const char *filename, int *byteorder)
if ( fileID == CDI_UNDEFID )
{
if ( strncmp(filename, "http:", 5) == 0 )
if ( memcmp(filename, "http:", 5) == 0 )
return (FILETYPE_NC);
else
return (CDI_ESYSTEM);
......@@ -122,7 +122,7 @@ static int getFiletype(const char *filename, int *byteorder)
fileRewind(fileID);
if ( strncmp(buffer, "GRIB", 4) == 0 )
if ( memcmp(buffer, "GRIB", 4) == 0 )
{
version = buffer[7];
if ( version <= 1 )
......@@ -131,17 +131,17 @@ static int getFiletype(const char *filename, int *byteorder)
if ( CDI_Debug ) Message(func, "found GRIB file = %s, version %d", filename, version);
}
}
else if ( strncmp(buffer, "CDF\001", 4) == 0 )
else if ( memcmp(buffer, "CDF\001", 4) == 0 )
{
filetype = FILETYPE_NC;
if ( CDI_Debug ) Message(func, "found CDF1 file = %s", filename);
}
else if ( strncmp(buffer, "CDF\002", 4) == 0 )
else if ( memcmp(buffer, "CDF\002", 4) == 0 )
{
filetype = FILETYPE_NC2;
if ( CDI_Debug ) Message(func, "found CDF2 file = %s", filename);
}
else if ( strncmp(buffer+1, "HDF", 3) == 0 )
else if ( memcmp(buffer+1, "HDF", 3) == 0 )
{
filetype = FILETYPE_NC4;
if ( CDI_Debug ) Message(func, "found HDF file = %s", filename);
......@@ -225,8 +225,8 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{
pch = &argument[i+1];
len -= (i+1);
if ( len && ( strncmp(argument, "filelist:", i) == 0 ||
strncmp(argument, "flist:", i) == 0 ) )
if ( len && ( memcmp(argument, "filelist:", i) == 0 ||
memcmp(argument, "flist:", i) == 0 ) )
{
for ( i = 0; i < len; ++i ) if ( pch[i] == ',' ) nfiles++;
......@@ -282,7 +282,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
}
}
}
else if ( len && strncmp(argument, "ls:", i) == 0 )
else if ( len && memcmp(argument, "ls:", i) == 0 )
{
char command[4096];
FILE *pfp;
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <math.h> /* modf */
#include <math.h> /* modf */
#include <float.h> /* FLT_EPSILON */
#include <sys/types.h>
......@@ -2101,7 +2101,7 @@ void grbDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int levelID
Warning(func, "pressure level of %f Pa is below 0.", level);
zaxisInqUnits(zaxisID, units);
if ( strncmp(units, "hPa", 3) == 0 || strncmp(units, "mb",2 ) == 0 )
if ( memcmp(units, "hPa", 3) == 0 || memcmp(units, "mb",2 ) == 0 )
level = level*100;
ilevel = (int) level;
......
......@@ -380,7 +380,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
Warning(func, "pressure level of %f Pa is below 0.", level);
zaxisInqUnits(zaxisID, units);
if ( strncmp(units, "hPa", 3) == 0 || strncmp(units, "mb",2 ) == 0 )
if ( memcmp(units, "hPa", 3) == 0 || memcmp(units, "mb",2 ) == 0 )
level = level*100;
ilevel = (int) level;
......
......@@ -158,7 +158,7 @@ int decodeForm1(char *pline, char *name, char *longname, char *units)
len = pline - pstart;
if ( len > 0 )
{
strncpy(name, pstart, len);
memcpy(name, pstart, len);
name[len] = 0;
}
else
......@@ -185,7 +185,7 @@ int decodeForm1(char *pline, char *name, char *longname, char *units)
len = pend - pstart + 1;
if ( len > 0 )
{
strncpy(longname, pstart, len);
memcpy(longname, pstart, len);
longname[len] = 0;
}
pstart = strrchr(pline, '[');
......@@ -200,7 +200,7 @@ int decodeForm1(char *pline, char *name, char *longname, char *units)
len = pend - pstart + 1;
if ( len > 0 )
{
strncpy(units, pstart, len);
memcpy(units, pstart, len);
units[len] = 0;
}
}
......@@ -227,7 +227,7 @@ int decodeForm2(char *pline, char *name, char *longname, char *units)
len = pend - pline;
if ( len > 0 )
{
strncpy(name, pline, len);
memcpy(name, pline, len);
name[len] = 0;
}
return (0);
......@@ -239,7 +239,7 @@ int decodeForm2(char *pline, char *name, char *longname, char *units)
len = pend - pline + 1;
if ( len > 0 )
{
strncpy(name, pline, len);
memcpy(name, pline, len);
name[len] = 0;
}
}
......@@ -254,7 +254,7 @@ int decodeForm2(char *pline, char *name, char *longname, char *units)
len = pend - pline + 1;
if ( len > 0 )
{
strncpy(longname, pline, len);
memcpy(longname, pline, len);
longname[len] = 0;
}
......@@ -269,7 +269,7 @@ int decodeForm2(char *pline, char *name, char *longname, char *units)
while ( isspace((int) *pend) ) pend--;
len = pend - pline + 1;
if ( len < 0 ) len = 0;
strncpy(units, pline, len);
memcpy(units, pline, len);
units[len] = 0;
}
......@@ -429,7 +429,7 @@ int tableInq(int modelID, int tablenum, const char *tablename)
{
/* len = strlen(parTable[tableID].name); */
len = strlen(tablename);
if ( strncmp(parTable[tableID].name, tablename, len) == 0 ) break;
if ( memcmp(parTable[tableID].name, tablename, len) == 0 ) break;
}
}
if ( tableID == MAX_TABLE ) tableID = UNDEFID;
......
......@@ -46,7 +46,7 @@ CDI_att *find_att(CDI_atts *attsp, const char *name)
{
attp = &(attsp->value[attid]);
if ( attp->namesz == slen )
if ( strncmp(attp->name, name, slen) == 0)
if ( memcmp(attp->name, name, slen) == 0)
{
return (attp); /* Normal return */
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment