touched up code for an old c++ compiler
This commit is contained in:
parent
c31d8dc8a2
commit
8118c7477d
@ -114,7 +114,7 @@ FULL_PATH_NAMES = YES
|
||||
# If left blank the directory from which doxygen is run is used as the
|
||||
# path to strip.
|
||||
|
||||
STRIP_FROM_PATH = @abs_top_srcdir@/include
|
||||
STRIP_FROM_PATH = @abs_top_srcdir@/include/
|
||||
|
||||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
|
||||
# the path mentioned in the documentation of a class, which tells
|
||||
|
@ -39,7 +39,7 @@ The \@include directive inserts the contents of the object specified in the
|
||||
following string, typically a file name, as if they appeared in the source
|
||||
stream being processed. The directive can only be used at the outmost scope
|
||||
where global variable declarations, BEGIN, END, and/or pattern-action blocks
|
||||
appear. To use @include, you must turn on QSE_AWK_INCLUDE.
|
||||
appear. To use \@include, you must turn on QSE_AWK_INCLUDE.
|
||||
|
||||
@code
|
||||
@include "abc.awk"
|
||||
|
@ -185,8 +185,8 @@ Writes the first line of the pattern space to @b file
|
||||
|
||||
- <b>s/rex/repl/opts</b>
|
||||
Finds a matching substring with @b rex in pattern space and replaces it
|
||||
with @repl. @b & in @b repl refers to the matching substring. @b opts may
|
||||
be empty; You can combine the following options into @opts:
|
||||
with @b repl. @b & in @b repl refers to the matching substring. @b opts may
|
||||
be empty; You can combine the following options into @b opts:
|
||||
- @b g replaces all occurrences of a matching substring with @b rex
|
||||
- @b number replaces the <b>number</b>'th occurrence of a matching substring
|
||||
with @b rex
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp 272 2009-08-28 09:48:02Z hyunghwan.chung $
|
||||
* $Id: Awk.hpp 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -74,9 +74,10 @@ public:
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Defines error numbers.
|
||||
*/
|
||||
///
|
||||
/// The ErrorNumber defines error numbers by redefining enumerators
|
||||
/// of the #qse_awk_errnum_t type.
|
||||
///
|
||||
enum ErrorNumber
|
||||
{
|
||||
ERR_NOERR = QSE_AWK_ENOERR,
|
||||
@ -198,60 +199,67 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The Awk::getErrorString() function returns a formatting string
|
||||
* for an error code @a num. You can override this function
|
||||
* to customize an error message. You must include the same numbers
|
||||
* of ${X}'s as the orginal formatting string. Their order may be
|
||||
* different. The example below changes the formatting string for
|
||||
* ERR_NOENT.
|
||||
* @code
|
||||
* const MyAwk::char_t* MyAwk::getErrorString (ErrorNumber num) const
|
||||
* {
|
||||
* if (num == ERR_NOENT) return QSE_T("cannot find '${0}'");
|
||||
* return Awk::getErrorString (num);
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
///
|
||||
/// The getErrorString() function returns a formatting string
|
||||
/// for an error code @a num. You can override this function
|
||||
/// to customize an error message. You must include the same numbers
|
||||
/// of ${X}'s as the orginal formatting string. Their order may be
|
||||
/// different. The example below changes the formatting string for
|
||||
/// ERR_NOENT.
|
||||
/// @code
|
||||
/// const MyAwk::char_t* MyAwk::getErrorString (ErrorNumber num) const
|
||||
/// {
|
||||
/// if (num == ERR_NOENT) return QSE_T("cannot find '${0}'");
|
||||
/// return Awk::getErrorString (num);
|
||||
/// }
|
||||
/// @endcode
|
||||
///
|
||||
virtual const char_t* getErrorString (
|
||||
ErrorNumber num
|
||||
) const;
|
||||
|
||||
public:
|
||||
/**
|
||||
* The Awk::getErrorNumber() function returns the number of the last
|
||||
* error occurred.
|
||||
*/
|
||||
///
|
||||
/// The getErrorNumber() function returns the number of the last
|
||||
/// error occurred.
|
||||
///
|
||||
ErrorNumber getErrorNumber () const;
|
||||
|
||||
/**
|
||||
* The Awk::getErrorLocation() function returns the location of the
|
||||
* last error occurred.
|
||||
*/
|
||||
///
|
||||
/// The getErrorLocation() function returns the location of the
|
||||
/// last error occurred.
|
||||
///
|
||||
loc_t getErrorLocation () const;
|
||||
|
||||
/**
|
||||
* The Awk::getErrorMessage() function returns a message describing
|
||||
* the last error occurred.
|
||||
*/
|
||||
///
|
||||
/// The Awk::getErrorMessage() function returns a message describing
|
||||
/// the last error occurred.
|
||||
///
|
||||
const char_t* getErrorMessage () const;
|
||||
|
||||
/**
|
||||
* Set error information.
|
||||
*/
|
||||
///
|
||||
/// The setError() function sets error information.
|
||||
///
|
||||
void setError (
|
||||
ErrorNumber code,
|
||||
const cstr_t* args = QSE_NULL,
|
||||
const loc_t* loc = QSE_NULL
|
||||
ErrorNumber code, ///< error code
|
||||
const cstr_t* args = QSE_NULL, ///< message formatting
|
||||
/// argument array
|
||||
const loc_t* loc = QSE_NULL ///< error location
|
||||
);
|
||||
|
||||
///
|
||||
/// The setErrorWithMessage() functions sets error information
|
||||
/// with a customized error message.
|
||||
///
|
||||
void setErrorWithMessage (
|
||||
ErrorNumber code,
|
||||
const char_t* msg,
|
||||
const loc_t* loc
|
||||
ErrorNumber code, ///< error code
|
||||
const char_t* msg, ///< error message
|
||||
const loc_t* loc ///< error location
|
||||
);
|
||||
|
||||
/** clears error information */
|
||||
///
|
||||
/// The clearError() function clears error information
|
||||
///
|
||||
void clearError ();
|
||||
|
||||
protected:
|
||||
@ -389,24 +397,34 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Pipe
|
||||
* The Pipe class encapsulates the pipe operations indicated by
|
||||
* the | and || operators.
|
||||
*/
|
||||
class Pipe: public RIOBase
|
||||
{
|
||||
public:
|
||||
friend class Awk;
|
||||
|
||||
/// The Mode type defines the opening mode.
|
||||
enum Mode
|
||||
{
|
||||
/// open for read-only access
|
||||
READ = QSE_AWK_RIO_PIPE_READ,
|
||||
/// open for write-only access
|
||||
WRITE = QSE_AWK_RIO_PIPE_WRITE,
|
||||
/// open for read and write
|
||||
RW = QSE_AWK_RIO_PIPE_RW
|
||||
};
|
||||
|
||||
/// The CloseMode type defines the closing mode for a pipe
|
||||
/// opened in the #RW mode.
|
||||
enum CloseMode
|
||||
{
|
||||
CLOSE_FULL = QSE_AWK_RIO_CLOSE_FULL,
|
||||
/// close both read and write ends
|
||||
CLOSE_FULL = QSE_AWK_RIO_CLOSE_FULL,
|
||||
/// close the read end only
|
||||
CLOSE_READ = QSE_AWK_RIO_CLOSE_READ,
|
||||
/// close the write end only
|
||||
CLOSE_WRITE = QSE_AWK_RIO_CLOSE_WRITE
|
||||
};
|
||||
|
||||
@ -414,11 +432,16 @@ public:
|
||||
Pipe (Run* run, rio_arg_t* riod);
|
||||
|
||||
public:
|
||||
/// The function returns the requested opening mode.
|
||||
/// The getMode() function returns the opening mode requested.
|
||||
/// You can inspect the opening mode, typically in the
|
||||
/// openPipe() function, to create a pipe with proper
|
||||
/// access mode. It is harmless to call this function from
|
||||
/// other pipe handling functions.
|
||||
Mode getMode () const;
|
||||
|
||||
/// The getCloseMode() function returns the requested closing
|
||||
/// mode. The returned value is valid if getMode() returns RW.
|
||||
/// The getCloseMode() function returns the closing mode
|
||||
/// requested. The returned value is valid if getMode()
|
||||
/// returns #RW.
|
||||
CloseMode getCloseMode () const;
|
||||
};
|
||||
|
||||
@ -743,7 +766,9 @@ public:
|
||||
{
|
||||
protected:
|
||||
friend class Awk;
|
||||
friend class Value;
|
||||
friend class Value;
|
||||
friend class RIOBase;
|
||||
friend class Console;
|
||||
|
||||
Run (Awk* awk);
|
||||
Run (Awk* awk, rtx_t* run);
|
||||
@ -834,11 +859,11 @@ public:
|
||||
|
||||
/**
|
||||
* The Awk::parse() function parses the source code read from the input
|
||||
* stream @a in and writes the parse tree to the output stream @out.
|
||||
* stream @a in and writes the parse tree to the output stream @a out.
|
||||
* To disable deparsing, you may set @a out to Awk::Source::NONE.
|
||||
* However, it is not legal to specify Awk::Source::NONE for @a in.
|
||||
* However, it is not allowed to specify Awk::Source::NONE for @a in.
|
||||
*
|
||||
* @return a Run object on success, #QSE_NULL on failure
|
||||
* @return Run object on success, #QSE_NULL on failure
|
||||
*/
|
||||
Awk::Run* parse (
|
||||
Source& in, ///< script to parse
|
||||
@ -990,7 +1015,7 @@ public:
|
||||
/**
|
||||
* Sets the value of a global variable identified by @a id.
|
||||
* The @a id is either a value returned by Awk::addGlobal or one of
|
||||
* Awk::Global enumerators. It is not legal to call this function
|
||||
* Awk::Global enumerators. It is not allowed to call this function
|
||||
* prior to Awk::parse.
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
@ -1002,7 +1027,7 @@ public:
|
||||
/**
|
||||
* Gets the value of a global riable identified by @a id.
|
||||
* The @a id is either a value returned by Awk::addGlobal or one of
|
||||
* Awk::::Global enumerators. It is not legal to call this function
|
||||
* Awk::::Global enumerators. It is not allowed to call this function
|
||||
* prior to Awk::parse.
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
@ -1062,8 +1087,17 @@ protected:
|
||||
* Pipe operations are achieved through the following functions.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/// The openPipe() function is a pure virtual function that must be
|
||||
/// overridden by a child class to open a pipe. It must return 1
|
||||
/// on success, 0 on end of a pipe, and -1 on failure.
|
||||
virtual int openPipe (Pipe& io) = 0;
|
||||
|
||||
/// The closePipe() function is a pure virtual function that must be
|
||||
/// overridden by a child class to close a pipe. It must return 0
|
||||
/// on success and -1 on failure.
|
||||
virtual int closePipe (Pipe& io) = 0;
|
||||
|
||||
virtual ssize_t readPipe (Pipe& io, char_t* buf, size_t len) = 0;
|
||||
virtual ssize_t writePipe (Pipe& io, const char_t* buf, size_t len) = 0;
|
||||
virtual int flushPipe (Pipe& io) = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.hpp 259 2009-08-20 11:28:03Z hyunghwan.chung $
|
||||
* $Id: StdAwk.hpp 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -24,12 +24,24 @@
|
||||
/** @file
|
||||
* Standard AWK Interpreter
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk05.cpp
|
||||
* This program demonstrates how to use QSE::StdAwk::loop().
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk06.cpp
|
||||
* This program demonstrates how to use QSE::StdAwk::call().
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk07.cpp
|
||||
* This program demonstrates how to handle an indexed value.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk08.cpp
|
||||
* This program shows how to add intrinsic functions.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h 272 2009-08-28 09:48:02Z hyunghwan.chung $
|
||||
* $Id: awk.h 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -26,17 +26,31 @@
|
||||
|
||||
/** @file
|
||||
* An embeddable AWK interpreter is defined in this header file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk.c
|
||||
* This program demonstrates how to build a complete awk interpreter.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk01.c
|
||||
* This program demonstrates how to use qse_awk_rtx_loop().
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk02.c
|
||||
* The program deparses the source code and prints it before executing it.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk03.c
|
||||
* This program demonstrates how to use qse_awk_rtx_call().
|
||||
* It parses the program stored in the string src and calls the functions
|
||||
* stated in the array fnc. If no errors occur, it should print 24.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example awk04.c
|
||||
* This programs shows how to qse_awk_rtx_call().
|
||||
*/
|
||||
@ -362,7 +376,7 @@ typedef enum qse_awk_rio_rwcmode_t qse_awk_rio_rwcmode_t;
|
||||
/**
|
||||
* The qse_awk_rio_arg_t defines the data structure passed to a runtime
|
||||
* I/O handler. An I/O handler should inspect the @a mode field and the
|
||||
* @a name field and store an open handle to the @handle field when
|
||||
* @a name field and store an open handle to the @a handle field when
|
||||
* #QSE_AWK_RIO_OPEN is requested. For other request type, it can refer
|
||||
* to the handle field set previously.
|
||||
*/
|
||||
@ -1567,7 +1581,7 @@ void qse_awk_rtx_geterrinf (
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_geterror() function retrieves error information from a
|
||||
* runtime context @rtx. The error number is stored into memory pointed
|
||||
* runtime context @a rtx. The error number is stored into memory pointed
|
||||
* to by @a errnum; the error message pointer into memory pointed to by
|
||||
* @a errmsg; the error line into memory pointed to by @a errlin.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: pio.h 244 2009-07-24 12:22:00Z hyunghwan.chung $
|
||||
* $Id: pio.h 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -173,7 +173,7 @@ extern "C" {
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (pio)
|
||||
|
||||
/**
|
||||
* The qse_pio_open() function executes a command @cmd and establishes
|
||||
* The qse_pio_open() function executes a command @a cmd and establishes
|
||||
* pipes to it. #QSE_PIO_SHELL causes the function to execute @a cmd via
|
||||
* the default shell of an underlying system: /bin/sh on *nix, cmd.exe on win32.
|
||||
* On *nix systems, a full path to the command is needed if it is not specified.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdSed.hpp 258 2009-08-19 14:04:15Z hyunghwan.chung $
|
||||
* $Id: StdSed.hpp 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -56,7 +56,9 @@ protected:
|
||||
* @example sed02.cpp
|
||||
* The example shows how to use the QSE::StdSed class to write a simple stream
|
||||
* editor that reads from a standard input and writes to a standard output.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example sed03.cpp
|
||||
* The example shows how to extend the QSE::StdSed class to read from and
|
||||
* write to a string.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sed.h 269 2009-08-26 03:03:51Z hyunghwan.chung $
|
||||
* $Id: sed.h 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -38,6 +38,9 @@
|
||||
* @todo
|
||||
* - enhance execution of the l(ell) command - consider adding a callback
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @example sed01.c
|
||||
* This example shows how to embed a basic stream editor.
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp 272 2009-08-28 09:48:02Z hyunghwan.chung $
|
||||
* $Id: Awk.cpp 275 2009-08-30 13:19:02Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -386,7 +386,7 @@ int Awk::Value::getInt (long_t* v) const
|
||||
run->awk->retrieveError (run);
|
||||
return -1;
|
||||
}
|
||||
if (n >= 1) lv = rv;
|
||||
if (n >= 1) lv = (long_t)rv;
|
||||
}
|
||||
|
||||
*v = lv;
|
||||
@ -410,7 +410,7 @@ int Awk::Value::getReal (real_t* v) const
|
||||
run->awk->retrieveError (run);
|
||||
return -1;
|
||||
}
|
||||
if (n == 0) rv = lv;
|
||||
if (n == 0) rv = (real_t)lv;
|
||||
}
|
||||
|
||||
*v = rv;
|
||||
|
13
qse/regress/awk/lang-034.awk
Normal file
13
qse/regress/awk/lang-034.awk
Normal file
@ -0,0 +1,13 @@
|
||||
BEGIN {
|
||||
print "15" || "sort";
|
||||
print "14" || "sort";
|
||||
print "13" || "sort";
|
||||
print "12" || "sort";
|
||||
print "11" || "sort";
|
||||
#close the input as sort emits when the input is closed
|
||||
close ("sort", "r");
|
||||
#close ("sort", "w");
|
||||
print "-----";
|
||||
while (("sort" || getline x) > 0) print "xx:", x;
|
||||
}
|
||||
|
@ -1666,6 +1666,27 @@ BEGIN {
|
||||
print x
|
||||
}
|
||||
--------------------------------------------------------------------------------
|
||||
../../cmd/awk/qseawk --newline=on --rwpipe=on -o- -f lang-034.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
BEGIN {
|
||||
print "15" || "sort";
|
||||
print "14" || "sort";
|
||||
print "13" || "sort";
|
||||
print "12" || "sort";
|
||||
print "11" || "sort";
|
||||
close ("sort","r");
|
||||
print "-----";
|
||||
while ((("sort" || getline x) > 0))
|
||||
print "xx:",x;
|
||||
}
|
||||
|
||||
-----
|
||||
xx: 11
|
||||
xx: 12
|
||||
xx: 13
|
||||
xx: 14
|
||||
xx: 15
|
||||
--------------------------------------------------------------------------------
|
||||
../../cmd/awk/qseawk -f quicksort.awk quicksort.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
0.0000000000
|
||||
|
@ -136,6 +136,7 @@ PROGS="
|
||||
lang-031.awk///--newline=on -o-
|
||||
lang-032.awk///--newline=on -o-
|
||||
lang-033.awk///--newline=on -o-
|
||||
lang-034.awk///--newline=on --rwpipe=on -o-
|
||||
|
||||
quicksort.awk/quicksort.dat//
|
||||
quicksort2.awk/quicksort2.dat//
|
||||
@ -189,7 +190,9 @@ init)
|
||||
;;
|
||||
test)
|
||||
run_scripts > "${OUTFILE}.temp"
|
||||
diff -q "${OUTFILE}" "${OUTFILE}.temp" || {
|
||||
# diff -q is not supported on old platforms.
|
||||
# redirect output to /dev/null instead.
|
||||
diff "${OUTFILE}" "${OUTFILE}.temp" > /dev/null || {
|
||||
echo_so "ERROR: ${OUTFILE} differs from ${OUTFILE}.temp."
|
||||
echo_so " Check the scripts and output files for any errors."
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user