LaTeX-BibTeX

 view release on metacpan or  search on metacpan

BibTeX.xs  view on Meta::CPAN

bt_cleanup()


# XSUBs that still go right into the LaTeX::BibTeX package (ie. they don't
# really belong in one of the subsidiary packages), but need a bit of work
# to convert the C data to Perl form:
#    split_list
#    purify_string

void
bt_split_list (string, delim, filename=NULL, line=0, description=NULL)

    char *   string
    char *   delim
    char *   filename
    int      line
    char *   description

    PREINIT:
       bt_stringlist *
             names;
       int   i;
       SV *  sv_name;

    PPCODE:
       names = bt_split_list (string, delim, filename, line, description);
       if (names == NULL)
          XSRETURN_EMPTY;       /* return empty list to perl */

       EXTEND (sp, names->num_items);
       for (i = 0; i < names->num_items; i++)
       {
          if (names->items[i] == NULL)
             sv_name = &PL_sv_undef;
          else
             sv_name = sv_2mortal (newSVpv (names->items[i], 0));

          PUSHs (sv_name);
       }

       bt_free_list (names);


SV *
bt_purify_string (instr, options=0)

    char *  instr
    int     options

    CODE:
       if (instr == NULL)               /* undef in, undef out */
          XSRETURN_EMPTY;
       RETVAL = newSVpv (instr, 0);
       bt_purify_string (SvPVX (RETVAL), (ushort) options);
       SvCUR_set (RETVAL, strlen (SvPVX (RETVAL))); /* reset SV's length */

    OUTPUT:
       RETVAL


# Here's an alternate formulation of `purify_string' that acts more like
# the C function (and less like nice Perl): it modifies the input string
# in place, and returns nothing.  In addition to being weird Perl,
# this contradicts the documentation.  And it would be impossible
# to replicate this behaviour in a similar Python extension... all
# round, a bad idea!

## void
## bt_purify_string (str, options=0)

##     char * str
##     int    options

##     CODE:
##        if (str != NULL) 
##           bt_purify_string (str, (ushort) options);
##           sv_setpv (ST(0), str);


SV *
bt_change_case (transform, string, options=0)
    char   transform
    char * string
    int    options

    CODE:
       DBG_ACTION
          (1, printf ("XSUB change_case: transform=%c, string=%p (%s)\n",
                      transform, string, string))                  
       if (string == NULL)
          XSRETURN_EMPTY;
       RETVAL = newSVpv (string, 0);
       bt_change_case (transform, SvPVX (RETVAL), (ushort) options);

    OUTPUT:
       RETVAL




MODULE = LaTeX::BibTeX   	PACKAGE = LaTeX::BibTeX::Entry

# The two XSUBs that go to the LaTeX::BibTeX::Entry package; both rely on
# ast_to_hash() to do the appropriate "convert to Perl form" work:
#    _parse
#    _parse_s

int
_parse (entry_ref, filename, file, preserve=FALSE)
    SV *    entry_ref;
    char *  filename;
    FILE *  file;
    boolean preserve;

    PREINIT:
        ushort  options = 0;
        boolean status;
        AST *   top;

    CODE:



( run in 0.964 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )