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

(-)rpm-4_0-4.0.4-orig/build/parseSpec.c (-1 / +34 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;/*tempory 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
      temp_fd = mkstemp(temp_filename_pattern);
428
      if (temp_fd == -1) {
429
	rpmError(RPMERR_CREATE, _("Cannot open tempory file"));
430
	return RPMERR_CREATE;
431
      }
432
      if (!(temp_file = fdopen(temp_fd, "w+b"))) {
433
	rpmError(RPMERR_CREATE, _("Cannot create tempory file descriptor"));
434
	return RPMERR_CREATE;
435
      }
436
      if (unlink(temp_filename_pattern) == -1) {
437
	rpmError(RPMERR_UNLINK, _("Cannot delete tempory file"));
438
	return RPMERR_UNLINK;
439
      }
440
    }
441
419
    if (buildRootURL) {
442
    if (buildRootURL) {
420
	const char * buildRoot;
443
	const char * buildRoot;
421
	(void) urlPath(buildRootURL, &buildRoot);
444
	(void) urlPath(buildRootURL, &buildRoot);
Lines 636-640 Link Here
636
    closeSpec(spec);
659
    closeSpec(spec);
637
    *specp = spec;
660
    *specp = spec;
638
661
662
    if (spec->preprocess_mode){
663
      if (!fseek(temp_file,0,SEEK_SET))
664
	while(fgets(line,255,temp_file))
665
	  printf("%s",line);
666
      else{
667
	rpmError(RPMERR_FSEEK, _("Cannot seek tempory file"));
668
	return RPMERR_FSEEK;
669
      }
670
    }
671
639
    return 0;
672
    return 0;
640
}
673
}

Return to bug 5662