*/
done = FALSE;
while (!done) { /* loop on each block in this word */
+ int ret = 0;
+
if (num_holes > MAX_REC_READ) {
num_reads = MAX_REC_READ;
num_holes -= MAX_REC_READ;
num_reads = num_holes;
}
errno = 0;
- fread (word_addrs, sizeof(DB_ADDR), (size_t)num_reads, fp_d99_old);
- if (errno) {
+ ret = fread (word_addrs, sizeof(DB_ADDR), (size_t)num_reads, fp_d99_old);
+ if (errno || -1 == ret) {
TERMINATE_LINE ();
fprintf (aa_stderr, catgets(dtsearch_catd, MS_dtsrclean, 657,
"%s Read error on %s: %s.\n"),
aa_stderr);
*readbuf = '\0';
- fgets (readbuf, sizeof(readbuf), stdin);
+ if(NULL == fgets (readbuf, sizeof(readbuf), stdin)) {
+ fprintf (aa_stderr, "Failed to read from stdin\n");
+ end_of_job (2, SHOW_EXITCODE);
+ }
if (strlen(readbuf) && readbuf[strlen(readbuf)-1] == '\n')
readbuf[strlen(readbuf)-1] = '\0';
}
/*-- Get next line --*/
do {
- fgets (prof_line, 200, prof);
+ char *ret = NULL;
+ ret = fgets (prof_line, 200, prof);
line_num++;
- if (feof (prof))
+ if (ret == NULL || feof (prof) )
break;
if (prof_line[0] == '#' || is_blank (prof_line))
continue;
got_word.or_hwoffset = ftell (dtbs_addr_fp);
got_word.or_hwfree = 0;
if (debugging & (DEBUG_n | DEBUG_N))
- printf ("APPEND ofs=%ld, fre=0\n", got_word.or_hwoffset);
+ printf ("APPEND ofs=%ld, fre=0\n", (long int) got_word.or_hwoffset);
}
else {
ret_fseek = fseek (dtbs_addr_fp,
num_addrs_for_word;
if (debugging & (DEBUG_n | DEBUG_N))
printf (" REUSE slot ofs=%ld, fre=%ld\n",
- got_word.or_hwoffset, got_word.or_hwfree);
+ (long int) got_word.or_hwoffset, (long int) got_word.or_hwfree);
}
/***** Write new database addresses to d99 file *********/
UPDATE_MAXDBA (objdba);
if (debug_mode)
printf ("---> new rec: inrecno %6ld, slot %6ld, key '%s'\n",
- input_reccount, objdba & 0xffffff, objrec.or_objkey);
+ (long int) input_reccount, (long int) objdba & 0xffffff, objrec.or_objkey);
/* Make current object record the owner of all its sets */
SETOR (PROGNAME "376", OR_OBJ_BLOBS, 0);
UPDATE_MAXDBA (objdba);
if (debug_mode)
printf ("----> update: inrecno %6ld, slot %6ld, key '%s'\n",
- input_reccount, objdba & 0xffffff, key);
+ (long int) input_reccount, (long int) objdba & 0xffffff, key);
/* Reinit certain fields.
* Objsize will be rewritten after new text size determined.
*/
else {
no_huffcode_file = FALSE;
- fgets (filebuf, sizeof (filebuf) - 1, instream_huf);
+ if(NULL == fgets (filebuf, sizeof (filebuf) - 1, instream_huf)) {
+ fprintf (stderr, "No first line in file\n");
+ exit(2);
+ }
/* discard this first line (don't need id stamp) */
while (fgets (filebuf, sizeof (filebuf) - 1, instream_huf)
!= NULL) {
#include <signal.h>
#include <sys/stat.h>
#include <locale.h>
+#include <stdlib.h>
#define PRINT_MESSAGES \
{ puts (DtSearchGetMessages()); DtSearchFreeMessages(); }
"\n...push ENTER to continue... ") );
*userbuf = '\0';
- fgets (userbuf, sizeof (userbuf), stdin);
+ if(NULL == fgets (userbuf, sizeof (userbuf), stdin)) {
+ fprintf(stderr, "Failed to read from stdin\n");
+ exit(EXIT_FAILURE);
+ }
if (strlen(userbuf) && userbuf[strlen(userbuf)-1] == '\n')
userbuf[strlen(userbuf)-1] = '\0';
"\n...push ENTER to continue... ") );
*userbuf = '\0';
- fgets (userbuf, sizeof (userbuf), stdin);
- if (strlen(userbuf) &&
+ if(NULL == fgets (userbuf, sizeof (userbuf), stdin)) {
+ fprintf(stderr, "Failed to read from stdin 2\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if (strlen(userbuf) &&
userbuf[strlen(userbuf)-1] == '\n')
userbuf[strlen(userbuf)-1] = '\0';
"If you are sure you are ready to start deleting, enter 'y' now... ") ,
infname, OE_prodname);
- fgets (buf, sizeof(buf)-1, stdin);
+ if(NULL == fgets (buf, sizeof(buf)-1, stdin)) {
+ fprintf(stderr, "no input\n");
+ return;
+ }
if (tolower (*buf) != 'y')
return;
}