octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

popen2 example gives no output


From: John W. Eaton
Subject: popen2 example gives no output
Date: Thu, 22 Sep 2005 16:05:21 -0400

On 12-Sep-2005, I wrote:

| (*) The ERRNO function is experimental.  Maybe it should be renamed
| "errno" instead.  Also, we need a way to get at all (most? some?) of
| the possible ERRNO values on a give system, perhaps by allowing
| something like
| 
|   EAGAIN = errno ("EAGAIN");

I'm looking at this now.  Since it is a development question I'm
moving the discussion from the bug list to the maintainers list.

The simple solution to associating the list of names and error codes
would be to have just the EXXX values that are defined by POSIX
(http://www.opengroup.org/onlinepubs/009695399/basedefs/errno.h.html)
but it seems that it would be better to have whatever symbolic names 
are available on a given system.  To implement this, we would need to
do some grepping through errno.h (and any files it includes).  That
seems ugly, and duplicates what Perl (at least) already does.  So it
seems to me that it would be cleaner to use Perl to generate the list
for Octave, when Octave is built.  That would introduce a build
dependency on Perl.  Is that a problem?  Perhaps we could fall back on
the list of names from POSIX if Perl is not available?  Otherwise, we
would have to duplicate a lot of fairly tricky code, and that seems
even less desirable to me.

Can some Perl guru on the list tell me how to use the Errno module in
Perl to generate a list of all the symbolic error codes, as strings?

Ultimately, I would like to generate code that looks something like
this:

  struct errno_name_value_struct
  {
    const char *name;
    const int value;
  };

  static errno_name_value_struct errno_codes
  {
    { "E2BIG", E2BIG },
    { "EACCESS", EACCESS },
    ...
    ...
    ...
    { 0, 0 },
  };

so we can implement

  EAGAIN = errno ("EAGAIN");

by doing something like (error checking omitted):

  octave_value retval = -1;

  std::string lookfor = args(0).string_value ();

  errno_name_value_struct *ptr = errno_codes;
  while (ptr->name)
    {
      if (lookfor == ptr->name)
        {
          retval = ptr->value;
          break;
        }
      else
        ptr++;
    }

  return retval;


Thanks,

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]