LaTeX-BibTeX

 view release on metacpan or  search on metacpan

BibTeX.xs  view on Meta::CPAN

#include "XSUB.h"

#define BT_DEBUG 0

#include "btparse.h"
#include "btxs_support.h"


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

# XSUBs with no corresponding functions in the C library (hence no prefix
# for this section):
#    constant

SV *
constant(name)
char *   name
        CODE:
	IV i;
	if (constant(name, &i))
	    ST(0) = sv_2mortal(newSViv(i));
	else
	    ST(0) = &PL_sv_undef;


MODULE = LaTeX::BibTeX           PACKAGE = LaTeX::BibTeX          PREFIX = bt_

# XSUBs that consist solely of calls to corresponding C functions in the
# library:
#    initialize
#    cleanup

void
bt_initialize()

void
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



( run in 1.224 second using v1.01-cache-2.11-cpan-5511b514fd6 )