View | Details | Raw Unified | Return to bug 5662
Collapse All | Expand All

(-)rpm-4_0-4.0.4-orig/build/parseSpec.c (-1 / +46 lines)
Lines 16-21 Link Here
16
16
17
/*@access FD_t @*/	/* compared with NULL */
17
/*@access FD_t @*/	/* compared with NULL */
18
18
19
static FILE* temp_file;/*temporary file to output preprocessing spec*/
20
19
/**
21
/**
20
 */
22
 */
21
/*@unchecked@*/
23
/*@unchecked@*/
Lines 362-368 Link Here
362
364
363
	if ( '\n' == chomped[len-1] ) 
365
	if ( '\n' == chomped[len-1] ) 
364
	    chomped[len-1] = '\0';
366
	    chomped[len-1] = '\0';
365
	puts( chomped );
367
	fprintf(temp_file, "%s\n", chomped );
366
	chomped = _free( chomped );
368
	chomped = _free( chomped );
367
    }
369
    }
368
370
Lines 396-401 Link Here
396
{
398
{
397
    rpmParseState parsePart = PART_PREAMBLE;
399
    rpmParseState parsePart = PART_PREAMBLE;
398
    int initialPackage = 1;
400
    int initialPackage = 1;
401
    char temp_filename_pattern[25]="preprocessed-spec.XXXXXX";
402
    int temp_fd;
403
    char line[255];
404
399
#ifdef	DYING
405
#ifdef	DYING
400
    const char *saveArch;
406
    const char *saveArch;
401
#endif
407
#endif
Lines 416-421 Link Here
416
    spec->fileStack = newOpenFileInfo();
422
    spec->fileStack = newOpenFileInfo();
417
    spec->fileStack->fileName = xstrdup(spec->specFile);
423
    spec->fileStack->fileName = xstrdup(spec->specFile);
418
    spec->preprocess_mode = preprocess;
424
    spec->preprocess_mode = preprocess;
425
426
    if (spec->preprocess_mode)
427
      if (!recursing){
428
	temp_fd = mkstemp(temp_filename_pattern);
429
	if (temp_fd == -1) {
430
	  rpmError(RPMERR_CREATE, _("Cannot open temporary file"));
431
	  return RPMERR_CREATE;
432
	}
433
	if (!(temp_file = fdopen(temp_fd, "w+b"))) {
434
	  rpmError(RPMERR_CREATE, _("Cannot create temporary file descriptor"));
435
	  return RPMERR_CREATE;
436
	}
437
	if (unlink(temp_filename_pattern) == -1) {
438
	  rpmError(RPMERR_UNLINK, _("Cannot delete temporary file"));
439
	  return RPMERR_UNLINK;
440
	}
441
      }else{	
442
	if (ftruncate(fileno(temp_file),0)){
443
	  /*FIX: witch error code should be use here?*/
444
	  rpmError(RPMERR_CREATE, _("Cannot truncate temporary file"));
445
	  return RPMERR_CREATE;
446
	}
447
448
	if (fseek(temp_file,0,SEEK_SET)){
449
	  rpmError(RPMERR_FSEEK, _("Cannot seek temporary file"));
450
	  return RPMERR_FSEEK;
451
	}
452
      }
453
    
419
    if (buildRootURL) {
454
    if (buildRootURL) {
420
	const char * buildRoot;
455
	const char * buildRoot;
421
	(void) urlPath(buildRootURL, &buildRoot);
456
	(void) urlPath(buildRootURL, &buildRoot);
Lines 636-640 Link Here
636
    closeSpec(spec);
671
    closeSpec(spec);
637
    *specp = spec;
672
    *specp = spec;
638
673
674
    if (spec->preprocess_mode){
675
      if (!fseek(temp_file,0,SEEK_SET))
676
	while(fgets(line,255,temp_file))
677
	  printf("%s",line);
678
      else{
679
	rpmError(RPMERR_FSEEK, _("Cannot seek temporary file"));
680
	return RPMERR_FSEEK;
681
      }
682
    }
683
639
    return 0;
684
    return 0;
640
}
685
}

Return to bug 5662