Ignore:
Timestamp:
Mar 27, 2007, 7:58:40 PM (18 years ago)
Author:
cinc
Message:

IDL compiler: improved outfile handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/c/nom-idl-compiler.c

    r276 r277  
    5555
    5656static gchar* chrOutputDir="";
    57 static gchar* chrOutputName="";
    5857static gboolean fOptionEmitH=FALSE;
    5958static gboolean fOptionEmitIH=FALSE;
     
    6766  {"emit-ih", 0, 0, G_OPTION_ARG_NONE, &fOptionEmitIH, "Emmit an include header (*.ih)", NULL},
    6867  {"emit-c", 0, 0, G_OPTION_ARG_NONE, &fOptionEmitC, "Emmit an implementation template (*.c)", NULL},
    69   {"output", 'o', 0, G_OPTION_ARG_FILENAME, &chrOutputName, "Output name. Must not be omitted.", NULL},
    7068  {NULL}
    7169};
     
    480478  helpCmd[0]=chrExeName;
    481479
    482   g_printf("An output filename must always be specified. If the name is an absolute path\n\
    483 it will be used unmodified. Otherwise the output name is built from the given\n\
    484 name and the directory specification.\n\n\
     480  g_printf("The output filename is specified in the IDL file using the 'filestem' keyword.\n\
    485481-If no directory is specified the output name is built from the current directory\n\
    486482 path and the given filename.\n\
     
    533529  /* Vars for filename building */
    534530  char* chrOutputFileName="";
    535   char* chrTemp;
    536531
    537532  GError *gError = NULL;
     
    565560  }
    566561
    567   if(strlen(chrOutputName)==0)
    568     {
    569       g_printf("No output file name given.\n\n");
    570       outputCompilerHelp(gContext, argv[0]);
    571     }
    572562  g_option_context_free(gContext);
    573563
     
    585575
    586576 
    587   /*** Create output file name ****/
    588   if(!g_path_is_absolute(chrOutputName))
    589     {
    590       if(g_path_is_absolute(chrOutputDir))
    591         chrOutputFileName=g_build_filename(chrOutputDir, chrOutputName, NULL);
    592       else
    593         {
    594           /* Yes this is a memory leak but I don't care */
    595           chrOutputFileName=g_build_filename(g_get_current_dir(), chrOutputDir, chrOutputName, NULL);
    596         }
    597     }
     577  /*** Create output path name ****/
     578  if(g_path_is_absolute(chrOutputDir))
     579    chrOutputFileName=chrOutputDir;
    598580  else
    599     chrOutputFileName=chrOutputName;
    600 
    601   /* Add emitter extension */
    602   if(fOptionEmitH)
    603     chrTemp=g_strconcat(chrOutputFileName, ".h", NULL);
    604   else if(fOptionEmitIH)
    605     chrTemp=g_strconcat(chrOutputFileName, ".ih", NULL);
    606   else if(fOptionEmitC)
    607     chrTemp=g_strconcat(chrOutputFileName, ".c", NULL);
    608   g_free(chrOutputFileName);
    609   chrOutputFileName=chrTemp;
    610 
    611   g_message("Output file: %s", chrOutputFileName);
     581    {
     582      /* Yes this is a memory leak but I don't care */
     583      chrOutputFileName=g_build_filename(g_get_current_dir(), chrOutputDir, NULL);
     584    }
     585
     586  g_message("Output path: %s", chrOutputFileName);
     587  parseInfo.chrOutfilePath=chrOutputFileName;
    612588
    613589  /* Open input */
     
    622598      exit(1);
    623599    }
    624  
    625   /* Open output */
    626   parseInfo.outFile=fopen(chrOutputFileName, "w");
    627600
    628601  g_printf("\n");
     
    663636
    664637#if 0
    665   else if(fOptionEmitIH)
    666 
    667638  else if(fOptionEmitC)
    668639    a++;
Note: See TracChangeset for help on using the changeset viewer.