home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
344_01
/
p2s.doc
< prev
next >
Wrap
Text File
|
1990-09-21
|
2KB
|
62 lines
Program:
* P2S
*
* printf() to streams i/o converter
*
* Description:
*
* Converts printf() calls to << operators
* Uses Lex to find printf's, fprintf's and sprintf's in C source
* and then uses p2s() call to convert the printf arguments to C++ streams
* formatted I/O.
* Does handle things like %6.2f (width and precision flags)
* by generating the appropriate streams manipulators - setw()
* and setprecision().
* Does NOT handle things like %-6.2f (yet) since there are no manipulators
* for left and right justification (if you decide to enhance this to
* handle this or anything else please submit back to CUG or me)
*
* stdin reads inoriginal C source, converted source goes to stdout.
*
* Usage:
*
* P2S < {.c file with printfs} > {file with streams i/o}
* Options:
* f - don't convert fprintf()'s
* p - don't convert printf()'s
* s - don't convert sprintf()'s
* i - converts by doing
* #ifdef __cplusplus
* ... streams code ..
* #else
* ... old printf code ...
* #endif
* to maintain backward compatibility with C (if desired)
*
* Example:
*
* For example to only convert fprintf calls and maintain C compatibility
* the invocation is:
*
* p2s p s i < foo.c >foo.cpp
*
*
* Construction:
*
* Just flex (or lex) this file, and compile the resultant C source.
* MKP2S.BAT shows how to make program with Flex and Turbo C.
*
* Restrictions:
*
* You may use this program without restriction as a tool in your own
* development efforts.
* You MAY NOT redistribute either the source or executables, in modified
* or unmodified form, for any amount of money or along with any other
* commercial package. You must include this copyright in any program
* which uses this source and you may not distribute such programs
* commercially. No restrictions apply to any programs which you converted
* using this tool (using the tool is unrestricted, distributing it or using
* its source is).
*
* Copyright (c) 1990. Adam Blum, Retrieval Systems Corporation,(703)-524-4534