Changeset da7341e


Ignore:
Timestamp:
Aug 16, 2017, 12:53:41 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
eea7bed4
Parents:
7f463cf
git-author:
Jason Gross <jgross@mit.edu> (07/12/11 13:20:32)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
Message:
Made owl_util_makepath available from perl

There's probably a better way to do this.  Maybe

sub makepath {
        my $filename = shift;
        $filename =~ s{ ^ ~ ( [^/]* ) } { $1 ? (getpwnam($1))[7]
        : ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7] ) }ex;
        return $filename;
}
(http://docstore.mik.ua/orelly/perl/cookbook/ch07_04.htm) or something.

Additionally, I'm not sure why

 PREINIT:
   char *rv = NULL;
 CODE:
 {
   rv = foo();
   RETVAL = rv;
 }
 OUTPUT:
   RETVAL
 CLEANUP:
   g_free(rv);

is the paradigm for functions returning strings, when foo returns `char
*` and not `const char *`.  I've removed the `= NULL` part of the
initlization, which I assume is left over from when we had to NULL-check
things before freeing them, but I've copied the rest of the code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlglue.xs

    r81e93c3 rda7341e  
    436436                RETVAL
    437437
     438const utf8 *
     439makepath(in)
     440        const char * in
     441        PREINIT:
     442                char *rv;
     443        CODE:
     444                rv = owl_util_makepath(in);
     445                RETVAL = rv;
     446        OUTPUT:
     447                RETVAL
     448        CLEANUP:
     449                g_free(rv);
     450
    438451void
    439452new_command(name, func, summary, usage, description)
Note: See TracChangeset for help on using the changeset viewer.