Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.os2.programmer.tools > #12 > unrolled thread

Force gnu assembler to invoke the preprocessor

Started byMarcel Müller <news.5.maazl@spamgourmet.org>
First post2011-06-19 12:28 +0200
Last post2011-06-19 11:24 -0700
Articles 9 — 4 participants

Back to article view | Back to comp.os.os2.programmer.tools


Contents

  Force gnu assembler to invoke the preprocessor Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-06-19 12:28 +0200
    Re: Force gnu assembler to invoke the preprocessor "A.D. Fundum" <what.ever@neverm.ind> - 2011-06-19 15:42 +0200
      Re: Force gnu assembler to invoke the preprocessor "A.D. Fundum" <what.ever@neverm.ind> - 2011-07-03 16:46 +0200
        DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) Andreas Schnellbacher <aschn@despammed.com> - 2011-07-04 00:44 +0200
          Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) "A.D. Fundum" <what.ever@neverm.ind> - 2011-07-04 11:09 +0200
            Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) "A.D. Fundum" <what.ever@neverm.ind> - 2011-07-21 22:54 +0200
              Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) "A.D. Fundum" <what.ever@neverm.ind> - 2011-07-24 12:23 +0200
              Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) "A.D. Fundum" <what.ever@neverm.ind> - 2011-07-24 12:32 +0200
    Re: Force gnu assembler to invoke the preprocessor Dave Yeo <dave.r.yeo@gmail.com> - 2011-06-19 11:24 -0700

#12 — Force gnu assembler to invoke the preprocessor

FromMarcel Müller <news.5.maazl@spamgourmet.org>
Date2011-06-19 12:28 +0200
SubjectForce gnu assembler to invoke the preprocessor
Message-ID<4dfdcf49$0$7624$9b4e6d93@newsspool1.arcor-online.net>
When i invoke as from gcc 3.3.5 to compile files from libmpg123, e.g. 
dct36_3dnow.S, the preprocessor is not used. The documentation says that 
as invoke the preprocessor if the file extension is an uppercase S. Most 
likely this is broken because OS/2 does not care about the case of file 
names.

Is there any option to force the preprocessor to run?

Currently I patched the make file and invoke the C compiler first, but 
this has several disadvantages.

.S.o:
    gcc -I$(TOPDIR) -DASSEMBLER -E $< -o $<.e
    $(GAS) $(GAFLAGS) $<.e -o $@


Marcel

[toc] | [next] | [standalone]


#13

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-06-19 15:42 +0200
Message-ID<o8uYFJ3iqTdG-pn2-lddw7WF8YUTz@localhost>
In reply to#12
 > invoke the preprocessor if the file extension is an uppercase S.
 > Most likely this is broken because OS/2 does not care about the
 > case of file names.

So it's not broken, because OS/2 cares by preserving the case of file 
names. The information isn't lost, albeit it's ignored in some cases 
(like DEL *.S). One should be able to detect the case of the S, at 
least with HPFS and JFS.


--

/* Kees.CMD */

CALL Lineout 'FOO.s',''
CALL LineOut 'FOO.s'
CALL Lineout 'BAR.S',''
CALL LineOut 'BAR.S'
CALL RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
CALL SysFileTree '*.S','file.','FO'
DO i=1 TO file.0
   IF Right(file.i,2)=='.S' THEN SAY 'Preprocessing' file.i
   IF Right(file.i,2)=='.s' THEN SAY 'Skipping' file.i
END i
'@DEL BAR.S > NUL'
'@DEL FOO.S > NUL'
EXIT

[toc] | [prev] | [next] | [standalone]


#15

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-07-03 16:46 +0200
Message-ID<o8uYFJ3iqTdG-pn2-dKTjwP0UB8sB@localhost>
In reply to#13
 > One should be able to detect the case of the S, at 
 > least with HPFS and JFS.

As an aside: is there an API or function which consistenly returns the
case of a directory as-is, with or without the drive letter?

Directory (full path: "D:\Download\Database\Europe\CAC40) with both 
_getcwd and the DosQueryCurrentDir API:

[D:\download\database\europe\cac40]c:printdir
D:\download\database\europe\cac40


But after those steps:

D:
CD \
CD Download

The output (and eCS' $p$g-prompt) then isn't "D:\download" but 
"D:\Download"...


--

[toc] | [prev] | [next] | [standalone]


#16 — DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)

FromAndreas Schnellbacher <aschn@despammed.com>
Date2011-07-04 00:44 +0200
SubjectDosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)
Message-ID<97c9mpF42tU1@mid.uni-berlin.de>
In reply to#15
A.D. Fundum wrote:

>> One should be able to detect the case of the S, at least with HPFS
>> and JFS.
>
> As an aside: is there an API or function which consistenly returns
> the case of a directory as-is, with or without the drive letter?
>
> Directory (full path: "D:\Download\Database\Europe\CAC40) with both
> _getcwd and the DosQueryCurrentDir API:
>
>  [D:\download\database\europe\cac40]c:printdir
>  D:\download\database\europe\cac40
>
> But after those steps:
>
>  D:
>  CD \
>  CD Download
>
> The output (and eCS' $p$g-prompt) then isn't "D:\download" but
> "D:\Download"...

A combination of DosQueryPathInfo with DosFind* works for me.
(DosFindNext returns the correct case, so SysFileTree may work as well
for REXX.)

-- 
Andreas Schnellbacher

[toc] | [prev] | [next] | [standalone]


#17 — Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-07-04 11:09 +0200
SubjectRe: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)
Message-ID<o8uYFJ3iqTdG-pn2-l1zCrydyidcP@localhost>
In reply to#16
 >> As an aside: is there an API or function which consistenly returns
 >> the case of a directory as-is, with or without the drive letter?

 > A combination of DosQueryPathInfo with DosFind* works for me.
 > (DosFindNext returns the correct case, so SysFileTree may work
 > as well for REXX.)

Thanks, so a combination may be required indeed. In an earlier example
in this (c.o.o.p.t.-) thread I used SysFileTree, which a.o. uses 
DosFind*, to distinguish between *.S and *.s file extensions, i.e. not
the full path name. 

BTW, I mean required for a good look, i.e. always preserving whatever 
the user entered explicitly.

Too bad trying another possibility also demonstrated a bug when e.g. 
an &eacute; was used as a final character. (MCD "x" is a combination 
of MD "x" and CD "x", which will also fail individually, with and 
without quotes). The Caf‚-subdirectory didn't exist before trying 
this:


[D:\Database]mcd Caf‚

[D:\Database\Caf‚]dir

The volume label in drive D is TEST.
The Volume Serial Number is A9C5:E150.
Directory of D:\Database

 4-07-11 10:48          <DIR>      0 ----  .
 4-07-11 10:48          <DIR>      0 ----  ..
 4-07-11 10:50          <DIR>      0 ----  Caf‚
        3 file(s)           0 bytes used
 

--

[toc] | [prev] | [next] | [standalone]


#19 — Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-07-21 22:54 +0200
SubjectRe: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)
Message-ID<cSWxyCWhUBcp-pn2-ukwFVnsMMr19@localhost>
In reply to#17
 >>> As an aside: is there an API or function which consistenly 
returns
 >>> the case of a directory as-is, with or without the drive letter?
 
 >> A combination of DosQueryPathInfo with DosFind* works for me.
 >> (DosFindNext returns the correct case, so SysFileTree may work
 >> as well for REXX.)

 > [D:\Database\Caf‚]dir

 > Directory of D:\Database
 > 4-07-11 10:50          <DIR>      0 ----  Caf‚

FTR: this seems to work. It prints the current directory of a drive, 
recursivly using DosFind* in the final stage to preserve, or rather 
respect, the original case.

Together with e.g. Sergey Yevtushenko's CLIP.CPP this already has some
use, possibly while installing software and creating WPS program 
objects. It's basicly the CMD.EXE-equivalent of a RMB on a WPS folder 
object to copy the full path of a directory to the eCS clipboard: 
"PRINTDIR | CLIP". 

I haven't embedded the clipboard funcionality, so PRINTDIR isn't 
DIR2CLIP. For one because the .subject-EA of a file downloaded with 
FF/SM also is a possible candidate to be copied to the clipboard, and 
I don't really want an *.EXE for each silly idea, with RFC #1 being a 
version which optionally adds quotes to the full path. Hey, write your
own Rexx 2Clip-frontend! ;-) 

--


/* ICC PRINTDIR.C, Q&D Worked At Least Once For Me Amateur Alert */

#define INCL_DOSFILEMGR

#include <direct.h>
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[])
{
APIRET rc;
char *buffer,buffer2[CCHMAXPATH],path[CCHMAXPATH],path2[CCHMAXPATH];
FILEFINDBUF3 filebuf={0};
HDIR hdir=HDIR_SYSTEM;
int drive=0,length,position;
ULONG filebuflen=sizeof(FILEFINDBUF3),searchlimit=1;

if (argc>2)
   {
   printf("Usage: PRINTDIR.EXE [drive]\n");
   return 1;
   }
if (argc==2)
   {
   if (strlen(argv[1])!=2)
      {
      printf("Usage: PRINTDIR.EXE [drive]\n");
      return 1;
      }
   if (argv[1][1]!=':')
      {
      printf("Usage: PRINTDIR.EXE [drive]\n");
      return 1;
      }
   if (argv[1][0]>90)
      argv[1][0]-=32;
   if (argv[1][0]<'A')
      {
      printf("Usage: PRINTDIR.EXE [drive]\n");
      return 1;
      }
   if (argv[1][0]>'Z')
      {
      printf("Usage: PRINTDIR.EXE [drive]\n");
      return 1;
      }
   drive=argv[1][0]-64;
   }

if (drive)
   buffer=_getdcwd(drive,buffer2,CCHMAXPATH);
else
   buffer=_getcwd(buffer2,CCHMAXPATH);
if (NULL==buffer)
   {
   fprintf(stderr,"SYS0021: The drive is not ready.\n");
   return 1;
   }

/* No root directory? DosFindFirst() each involved (sub-)directory */
if (strlen(buffer)>3)
   {
   while (strlen(buffer)>3)
      {
      rc=DosFindFirst(buffer,&hdir,FILE_DIRECTORY,&filebuf,filebuflen
                      &searchlimit,FIL_STANDARD);      
      if (rc)
         {
         fprintf(stderr,"DosFindFirst() error: rc=%u\n",rc);
         return 1;
         }
      length=strlen(buffer);   
      position=length;
      while (buffer[position]!='\\'&&position>3)
         --position;
      buffer[position]='\0';
      if (strlen(path))
         sprintf(path2,"%s\\%s",filebuf.achName,path);
      else
         sprintf(path2,"%s",filebuf.achName);
      sprintf(path,"%s",path2);
      rc=DosFindClose(hdir);
      if (rc)
         {
         fprintf(stderr,"DosFindClose() error: rc=%u\n",rc);
         return 1;
         }
      }
   strcat(buffer,path);
   }

if (strlen(buffer)<3)
   {
   fprintf(stderr,
           "Error: unexpected number of characters (%u) in %s\n",
           strlen(buffer),buffer);
   return 1;
   }

printf("%s\n",buffer);

return 0;
}

[toc] | [prev] | [next] | [standalone]


#20 — Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-07-24 12:23 +0200
SubjectRe: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)
Message-ID<o8uYFJ3iqTdG-pn2-9dlCE1rTjZYh@localhost>
In reply to#19
 >> (DosFindNext returns the correct case, so SysFileTree may
 >> work as well for REXX.)

Rexx version, if needed also with more than a single underlying 
DosFind*-call:

--

/* PrintDir.CMD */

CALL RxFuncAdd 'SysDriveMap','RexxUtil','SysDriveMap'
CALL RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'

ARG argv

IF Left(argv,1)='"' THEN PARSE VAR argv '"' argv '"' .

here=Directory()
drive=Left(Directory(),2)

IF Arg()>1 THEN DO
   SAY "Usage: PrintDir.CMD [optional, drive, e.g. C:]"
   EXIT 1
END

IF Arg()=1 THEN DO
   IF Length(argv)<>2 THEN DO
      SAY "Usage: PrintDir.CMD [optional, drive, e.g. C:]"
      EXIT 1
   END

   IF argv<'A:' | argv>'Z:' | Right(argv,1)<>':' THEN DO
      SAY "Usage: PrintDir.CMD [optional, drive, e.g. C:]"
      EXIT 1
   END
   drive=argv
END

IF Pos(drive,SysDriveMap('A:'),1)=0 THEN DO
   SAY 'SYS0021: The drive is not ready.' 
   RETURN 1
   EXIT
END

fullpath=Directory(drive)
CALL Directory here
IF Length(fullpath)>3 THEN DO
   count=0
   DO i=1 TO CountStr('\',fullpath)+1
      PARSE VAR fullpath part.i '\' fullpath
      count=count+1
   END i
   fullpath=part.1
   DO i=2 TO count
      rc=SysFileTree(fullpath||'\'||part.i,'DIRS.','DO')      
      IF rc=2 THEN DO
         SAY 'SysFileTree() error: rc='||rc
         EXIT 1
      END
      IF dirs.0<>1 THEN DO
         SAY 'Error: directory' part.i 'not found'
         EXIT 1
      END
      fullpath=fullpath||'\'||FileSpec('N',dirs.1)
   END i
END

IF Length(fullpath)<3 THEN DO
   SAY "Error: unexpected number of characters ("||Length(fullpath),
       ||") in" fullpath
   EXIT 1
END

SAY fullpath

EXIT

[toc] | [prev] | [next] | [standalone]


#21 — Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)

From"A.D. Fundum" <what.ever@neverm.ind>
Date2011-07-24 12:32 +0200
SubjectRe: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor)
Message-ID<o8uYFJ3iqTdG-pn2-elEVuPKf3frN@localhost>
In reply to#19
 > Together with e.g. Sergey Yevtushenko's CLIP.CPP this already has
 > some use: "PRINTDIR | CLIP" 

 > I haven't embedded the clipboard funcionality, so PRINTDIR isn't
 > DIR2CLIP. For one because the .subject-EA of a file downloaded
 > with FF/SM also is a possible candidate to be copied to the
 > clipboard

 > Hey, write your own Rexx 2Clip-frontend! ;-) 

[D:\database\paris\cac40]PRINTSEA d:\bbox\q1.zip
http://hobbes.mnsu.edu/download/private/hq/meetings/q12011.zip

--


/* PrintsEA.CMD, Print s(ubject) EA of a file */

CALL RxFuncAdd 'SysGetEA','RexxUtil','SysGetEA'

PARSE ARG file

IF arg()<>1 THEN DO
   SAY 'Usage: PrintsEA <file>'
   EXIT 1
END

file=Strip(file)
IF Left(file,1)='"' THEN PARSE VAR file '"' file '"' .
 
IF Stream(file,'C','QUERY EXISTS')='' THEN DO 
   SAY 'Error: file' file 'not found'
   EXIT 1
END

rc=SysGetEA(file,'.subject','URL')

IF url='' THEN DO
   SAY 'Error: no ".subject" extended attribute found'
   EXIT 1
END

PARSE VAR url 1 . 5 url
IF Pos('://',url,1)<2 THEN DO
   SAY 'Error: no URL found in the ".subject" extended attribute'
   EXIT 1
END

SAY url

EXIT

[toc] | [prev] | [next] | [standalone]


#14

FromDave Yeo <dave.r.yeo@gmail.com>
Date2011-06-19 11:24 -0700
Message-ID<itlers$v04$1@speranza.aioe.org>
In reply to#12
Marcel Müller wrote:
> When i invoke as from gcc 3.3.5 to compile files from libmpg123, e.g.
> dct36_3dnow.S, the preprocessor is not used. The documentation says that
> as invoke the preprocessor if the file extension is an uppercase S. Most
> likely this is broken because OS/2 does not care about the case of file
> names.
>
> Is there any option to force the preprocessor to run?
>
> Currently I patched the make file and invoke the C compiler first, but
> this has several disadvantages.
>
> .S.o:
> gcc -I$(TOPDIR) -DASSEMBLER -E $< -o $<.e
> $(GAS) $(GAFLAGS) $<.e -o $@
>
>
> Marcel

This has usually worked here, using a case preserving filesystem. Only 
problem I've run into has been when there are 2 files, foo.s and foo.S.
Dave

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.os2.programmer.tools


csiph-web