Changeset e7ab1d7


Ignore:
Timestamp:
Jan 7, 2014, 6:00:46 PM (8 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
dca6255
Parents:
c877a63
git-author:
Jason Gross <jgross@mit.edu> (07/12/11 13:20:32)
git-committer:
Jason Gross <jgross@mit.edu> (01/07/14 18:00:46)
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

    r7dcef03 re7ab1d7  
    408408                RETVAL
    409409
     410const utf8 *
     411makepath(in)
     412        const char * in
     413        PREINIT:
     414                char *rv;
     415        CODE:
     416                rv = owl_util_makepath(in);
     417                RETVAL = rv;
     418        OUTPUT:
     419                RETVAL
     420        CLEANUP:
     421                g_free(rv);
     422
    410423void
    411424new_command(name, func, summary, usage, description)
Note: See TracChangeset for help on using the changeset viewer.