char *title = NULL;
char *charSet = (char *) DefCharSet;
char *abstract = NULL;
- char *filename = NULL;
char *pathName = NULL;
VolumeHandle volume = NULL;
if (title)
free ((void *) title);
- if (filename)
- free ((void *) filename);
return result;
}
}
/* Alloc max shell command line len */
- printCommand = malloc(MAX_COMMAND_LENGTH*sizeof(char));
+ printCommand = malloc(MAX_COMMAND_LENGTH);
if (printCommand == NULL)
{
fprintf(stderr, _DTGETMESSAGE(PMSET,5,
+
"%s: Error: memory allocation failed\n"),
options->programName );
/** generate the command **/
snprintf(cmdFormat, sizeof(cmdFormat), "%s %s", /* man */
options->manCommand, options->manArgs);
- snprintf(printCommand, sizeof(MAX_COMMAND_LENGTH*sizeof(char)), cmdFormat,
+ snprintf(printCommand, MAX_COMMAND_LENGTH, cmdFormat,
options->manPage); /* man */
retval = _DtHPrGenFileOrPrint(options,options->manPage,printCommand);
/* if processing subtopics, start processing at the top */
if ( processSubTopics )
{
- char * name = NULL;
int offset;
/* get the top topic of the volume */
ret = _DtHelpCeGetTopTopicId(state->volHandle, &state->currentLocId);
if (ret != True) state->currentLocId = strdup("_HOMETOPIC");
- if(name) free(name);
}
else
{ /* otherwise, process only where needed */
char * buf;
char * start;
char * next;
- char * pgbrkFile;
+ char * pgbrkFile = NULL;
char * partFiles[NUMPARTS];
Boolean validFile = False;
unlink(partFiles[i]);
free(partFiles[i]);
}
- unlink(pgbrkFile);
+
+ if(pgbrkFile) {
+ unlink(pgbrkFile);
+ }
/* NOTE: should free Toc here if interested in no leaks */
pTemp = pCacheListHead;
/* Search our Cache List for the closed help dialog */
- while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
+ while ((pTemp != NULL) && (pTemp->helpDialog != helpDialog))
pTemp = pTemp->pNext;
- if (pTemp == NULL)
+ if (pTemp == NULL) {
/* ERROR */
printf("We did not find our help dialog widget in the cache list??? /n");
+ /* TODO what error handling here? */
+ return;
+ }
/* Un Map and Clean up the help widget */
XtUnmanageChild(helpDialog);
fprintf(stderr, "**** Specify interface file ****\n") ;
exit(TRUE) ;
}
- strncpy(iffile, argv[1], IFLEN) ;
+ snprintf(iffile, sizeof(iffile), "%s", argv[1]) ;
initialize() ;
while (TRUE) {
m_token = scan() ;
else
{
/* not fully specified, check each component of path for ourself */
- strcpy(patbuf, getenv("PATH"));
+ snprintf(patbuf, sizeof(patbuf), "%s", getenv("PATH"));
path = patbuf;
cp = path;
{
unsigned char etype, wheredef;
char *mb_content, *ssi, id[32];
-static M_WCHAR empty = M_EOS;
+static M_WCHAR empty[1];
char *leftright;
+empty[0] = M_EOS;
+
/* handle graphic specific code */
/* initialize some stuff first:
gentity);
}
}
- if (!f_content) f_content = ∅
+ if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(id, "%s%d", sdlReservedName, NextId());
char *item_id;
char label_id[SDLNAMESIZ+10];
int listtype;
-char *type;
+char *type = NULL;
char *loose;
char *first;
LOGICAL isBullet, isLoose, isFirst;
switch (lastlist->lastlist->order)
{
case UROMAN:
- strcpy(orderString, ROMAN100[count / 100]);
- strcat(orderString, ROMAN10[(count / 10) % 10]);
- strcat(orderString, ROMAN0[count % 10]);
+ snprintf(orderString, sizeof(orderString), "%s%s%s",
+ ROMAN100[count / 100],
+ ROMAN10[(count / 10) % 10],
+ ROMAN0[count % 10]);
type = romanString;
break;
case UALPHA:
type = arabicString;
break;
case LROMAN:
- strcpy(orderString, roman100[count / 100]);
- strcat(orderString, roman10[(count / 10) % 10]);
- strcat(orderString, roman0[count % 10]);
+ snprintf(orderString, sizeof(orderString), "%s%s%s",
+ roman100[count / 100],
+ roman10[(count / 10) % 10],
+ roman0[count % 10]);
type = romanString;
break;
case LALPHA:
"%s%s-%s\">\n<P>%s%c",
first,
loose,
- type,
+ type ? type : "",
orderString,
lastlist->lastlist->punct == DOTPUNCT ? '.' : ')' );
if (id)
char myPlatform[_DtPLATFORM_MAX_LEN+1];
char myLocale[256]; /* arbitrarily large */
char *locale;
-char *lang;
-char *charset;
+char *lang = NULL;
+char *charset = NULL;
int execVer;
int compVer;
int isStd;
-strcpy(myLocale, pLang);
if (*pCharset)
{
- strcat(myLocale, ".");
- strcat(myLocale, pCharset);
+ snprintf(myLocale, sizeof(myLocale), "%s.%s", pLang, pCharset);
+ }
+else
+ {
+ snprintf(myLocale, sizeof(myLocale), "%s", pLang);
}
if ((_DtLcxOpenAllDbs(&myDb) != 0) ||
if (*lang)
{
strcpy(pLang, lang);
- mb_free(&lang);
}
else
strcpy(pLang, cString);
if (*charset)
{
strcpy(pCharset, charset);
- mb_free(&charset);
- free(charset);
}
else
strcpy(pCharset, isoString);
}
+ mb_free(&lang);
+ mb_free(&charset);
+ free(charset);
+
+
_DtLcxCloseDb(&myDb);
}
if (dotPtr)
*dotPtr = 0;
-strcpy(stdLang, locale);
+snprintf(stdLang, sizeof(stdLang), "%s", locale);
if (charset)
- strcpy(stdCharset, charset);
+ snprintf(stdCharset, sizeof(stdCharset), "%s", charset);
SetStdLocale(stdLang, stdCharset);
if (*stdCharset)
sprintf(snb_id, "%s%d", sdlReservedName, NextId());
{
-static M_WCHAR empty = M_EOS;
+static M_WCHAR empty[1];
char *mb_content;
+empty[0] = M_EOS;
+
-if (!f_content) f_content = ∅
+if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
AddToSNB(snb_id, mb_content);
fputs("CLASS=\"ICON\" SSI=\"NCW-ICON\">", outfile);
fputs("</REFITEM>\n</SNREF></HEAD>\n", outfile);
AddToSNB(id, icon);
- m_free(icon, "icon name");
}
+m_free(icon, "icon name");
}
else
try = mb_realloc(try, tryleng);
}
- strcpy(try, thispath->directory);
- strcpy(try + pathleng, mb_inputname);
+ sprintf(try, "%s%s", thispath->directory, mb_inputname);
tossfile = open(try, O_RDONLY);
if (tossfile >= 0) break;
thispath = thispath->next;
if (termp - term > 1 && *(termp-1) == ' ') {
*(termp-1) = M_EOS;
}
- if (!(lastTermId = (int) m_lookfortrie(term, >ree)))
+ if (!(lastTermId = (int)(intptr_t) m_lookfortrie(term, >ree)))
{
lastTermId = NextId();
- m_ntrtrie(term, >ree, (void *) -lastTermId);
+ m_ntrtrie(term, >ree, (void *)(intptr_t) -lastTermId);
}
else
if (lastTermId > 0)
{
- if (!m_resettrie(>ree, term, (void *) -lastTermId))
+ if (!m_resettrie(>ree, term, (void *)(intptr_t) -lastTermId))
{
m_error("Internal error. Can't reset glossary trie") ;
m_exit(TRUE) ;
m_error("Program error: exceeded chapstring") ;
m_exit(TRUE) ;
}
- sprintf(chapstring, sizeof(chapstring), "%s", string) ;
+ snprintf(chapstring, sizeof(chapstring), "%s", string) ;
fputs("\nGlossary\n", stderr) ;
glossary = TRUE ;
fprintf(outfile, "<HEAD SSI=\"CHAPHEAD\">%s</HEAD>\n", string);
{
char *mb_content, snb_id[32];
char buffer[BIGBUF];
- static M_WCHAR empty = M_EOS;
+ static M_WCHAR empty[1];
+ empty[0] = M_EOS;
- if (!f_content) f_content = ∅
+ if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(snb_id, "%s%d", sdlReservedName, NextId());
exLineNum++;
if (special[index])
{
- strcpy(exbuff, special[index]);
+ snprintf(exbuff, sizeof(exbuff), "%s", special[index]);
bufflen = strlen(exbuff);
}
}
index = (unsigned char) imbuff[0];
if (special[index])
{
- strcpy(imbuff, special[index]);
+ snprintf(imbuff, sizeof(imbuff), "%s", special[index]);
bufflen = strlen(imbuff);
}
mb_strcode(imbuff, outfile);
int nameindex ;
LOGICAL start ;
- strncpy(efilename, fname, ENTFILENAME) ;
- strncpy(&efilename[strlen(efilename)], ".h", 2) ;
+ snprintf(efilename, sizeof(efilename), "%s.h", fname) ;
m_openchk(&entfile, efilename, "w") ;
fprintf(entfile, "#include \"entdef.h\"\n") ;
char *mb_entcontent;
mb_entcontent = MakeMByteString(entcontent);
-if (!*mb_entcontent) return NULL; /* null file name, don't open a directory */
+if (!*mb_entcontent) /* null file name, don't open a directory */
+ {
+ m_free(mb_entcontent, "multi-byte string");
+ return NULL;
+ }
open = fopen(mb_entcontent, "r");
if (open)
if (q = strstr(p, VERSION)) {
pCopy = strdup(p);
q = strstr(pCopy, VERSION);
- *q = M_EOS;
+ if(q) {
+ *q = M_EOS;
+ }
m_errline(pCopy);
free(pCopy);
return;
{
char *mb_content, snb_id[32];
char buffer[BIGBUF];
- static M_WCHAR empty = M_EOS;
+ static M_WCHAR empty[1];
+ empty[0] = M_EOS;
- if (!f_content) f_content = ∅
+ if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(snb_id, "%s%d", sdlReservedName, NextId());
strcpy(helpext, ".xrh");
tex = fopen(helpbase, "w");
+if (! tex) {
+ return;
+}
fprintf(tex, "\\gobble\001%s\002%%\n", m_signon);
fputs("% Generated Cross-Reference Macros (for a particular document)\n", tex);
if (! xtree.data) {
#if defined(MSDOS)
if (m_heapchk) m_heapdump() ;
#endif
- free(block) ;
if (m_malftrace) {
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__)
snprintf(buffer, 32, "%5x:%5x",
m_trace(msg) ;
m_trace("\n") ;
}
+ free(block) ;
#if defined(MSDOS)
if (m_heapchk) m_heapdump() ;
#endif
void srefout(M_NOPAR)
{
LOGICAL first = TRUE ;
- int *mapbysref ;
+ int *mapbysref = NULL;
SREFSTRUCT *srefp ;
SREFDATA *data ;
int count = 0 ;
#endif
{
ElementPtr pThis;
-M_WCHAR *rlevel, *rclass, *rssi;
+M_WCHAR *rlevel = NULL, *rclass = NULL, *rssi = NULL;
LOGICAL *pBeenUsed;
pThis = pTossChain;