Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
Public.Tools.Language.Hyphenate
Viewing contents of Public_Tools_Language_Hyphenate-1.3/hyphenate.c

/* Generated from "hyphenate.cmod" by precompile.pike running Pike v8.0 release 182
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 6

#undef PRECOMPILE_SUB_PIKEVARS
#define PRECOMPILE_SUB_PIKEVARS 1

#undef PRECOMPILE_DYNAMIC_TYPES
#define PRECOMPILE_DYNAMIC_TYPES 1



#undef cmod___CMOD__
#define cmod___CMOD__ 1
#line 1 "hyphenate.cmod"
#line 1 "hyphenate.cmod"
#line 1 "hyphenate.cmod"
#line 2998 "/usr/local/pike/8.0.182/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"







#line 3005 "/usr/local/pike/8.0.182/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"
#line 1 "hyphenate.cmod"
/*! @module Public
 */

/*! @module Tools
 */

/*! @module Language
 */

#line 10 "hyphenate.cmod"
#define _GNU_SOURCE
#define DEFAULT_CMOD_STORAGE

#include "hyphenate_config.h"
#include "util.h"
#include "hyphen-2.8.6/hyphen.h"


/*! @class Hyphenate
 */


#undef class_Hyphenate_Hyphenate_defined
#define class_Hyphenate_Hyphenate_defined
DEFAULT_CMOD_STORAGE struct program *Hyphenate_Hyphenate_program=NULL;

#ifdef Hyphenate_Hyphenate_program_fun_num_used
DEFAULT_CMOD_STORAGE int Hyphenate_Hyphenate_program_fun_num=-1;
#endif /* Hyphenate_Hyphenate_program_fun_num_used */

#undef var_dict_Hyphenate_Hyphenate_defined
#define var_dict_Hyphenate_Hyphenate_defined

#undef THIS
#define THIS ((struct Hyphenate_Hyphenate_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_HYPHENATE_HYPHENATE
#define THIS_HYPHENATE_HYPHENATE ((struct Hyphenate_Hyphenate_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_HYPHENATE_HYPHENATE
#define OBJ2_HYPHENATE_HYPHENATE(o) ((struct Hyphenate_Hyphenate_struct *)(o->storage+Hyphenate_Hyphenate_storage_offset))

#undef GET_HYPHENATE_HYPHENATE_STORAGE
#define GET_HYPHENATE_HYPHENATE_STORAGE(o) ((struct Hyphenate_Hyphenate_struct *)(o->storage+Hyphenate_Hyphenate_storage_offset)
static ptrdiff_t Hyphenate_Hyphenate_storage_offset;
struct Hyphenate_Hyphenate_struct {

#ifdef var_dict_Hyphenate_Hyphenate_defined
#line 24 "hyphenate.cmod"
HyphenDict * dict;
#endif /* var_dict_Hyphenate_Hyphenate_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Hyphenate_Hyphenate_struct *Hyphenate_Hyphenate_gdb_dummy_ptr;
#endif
/*! @decl void create(string appname)
 *!   Creates a new Hyphenate object
 *!
 */
#define f_Hyphenate_Hyphenate_create_defined

#ifdef f_Hyphenate_Hyphenate_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Hyphenate_Hyphenate_create_fun_num = 0;

#endif /* f_Hyphenate_Hyphenate_create_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Hyphenate_Hyphenate_create(INT32 args) {
#line 30 "hyphenate.cmod"
struct pike_string * dictionary;
#line 30 "hyphenate.cmod"
if(args != 1) wrong_number_of_args_error("create",args,1);
#line 30 "hyphenate.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("create",1,"string");
#line 30 "hyphenate.cmod"
debug_malloc_pass(dictionary=Pike_sp[0-1].u.string);
{
HyphenDict * hd;
char * dn;
/*printf("create()\n"); */
dn = strdup(dictionary->str);
hd = hnj_hyphen_load(dn);

if(!hd)
{
Pike_error("unable to load hyphenation dictionary.\n");
}

THIS->dict = hd;

pop_n_elems(args);
}

}
#define f_Hyphenate_Hyphenate_low_hyphenate_defined

#ifdef f_Hyphenate_Hyphenate_low_hyphenate_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Hyphenate_Hyphenate_low_hyphenate_fun_num = 0;

#endif /* f_Hyphenate_Hyphenate_low_hyphenate_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Hyphenate_Hyphenate_low_hyphenate(INT32 args) {
#line 48 "hyphenate.cmod"
struct pike_string * word;
#line 48 "hyphenate.cmod"
if(args != 1) wrong_number_of_args_error("low_hyphenate",args,1);
#line 48 "hyphenate.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("low_hyphenate",1,"string");
#line 48 "hyphenate.cmod"
debug_malloc_pass(word=Pike_sp[0-1].u.string);
{
int k, n, i, j, c;

char** rep;
int* pos;
int* cut;

int nHyphCount;
char *hyphens;
char *hyphword;

rep = NULL; /* Will be allocated by the algorithm */
pos = NULL; /* Idem */
cut = NULL; /* Idem */

k = word->len * (1 << word->size_shift);

/* set aside some buffers to hold lower cased */
/* and hyphen information */
hyphens = (char *)malloc(k+5);

if (k > 0) {
if(hnj_hyphen_hyphenate2(THIS->dict, word->str, word->len, hyphens,
NULL, &rep, &pos, &cut))
{
free(hyphens);
pop_n_elems(args);
Pike_error("hyphenation error\n");
}

/* now backfill hyphens[] for any removed periods */
for (c = word->len; c < k; c++) hyphens[c] = '0';
hyphens[k] = '\0';

/* now create a new char string showing hyphenation positions */
/* count the hyphens and allocate space for the new hypehanted string */
nHyphCount = 0;
for(i = 0; i < word->len; i++)
{ 
if(hyphens[i]&1)
nHyphCount++;
} 

hyphword = (char *) malloc(k+1+nHyphCount);
j = 0;
for (i = 0; i < word->len; i++) 
{
hyphword[j++] = word->str[i];
if (hyphens[i]&1)
{
hyphword[j++] = '-';
}
} 

hyphword[j] = '\0';

pop_n_elems(args); 
push_text(hyphword);
free(hyphens);
free(hyphword);
/*	    } */
}
}

}
/*! @decl string hyphenate(string word)
 *!
 *! Break a word into its possible hyphenations.
 */
#define f_Hyphenate_Hyphenate_hyphenate_defined

#ifdef f_Hyphenate_Hyphenate_hyphenate_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Hyphenate_Hyphenate_hyphenate_fun_num = 0;

#endif /* f_Hyphenate_Hyphenate_hyphenate_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Hyphenate_Hyphenate_hyphenate(INT32 args) {
#line 117 "hyphenate.cmod"
struct pike_string * word;
#line 117 "hyphenate.cmod"
if(args != 1) wrong_number_of_args_error("hyphenate",args,1);
#line 117 "hyphenate.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("hyphenate",1,"string");
#line 117 "hyphenate.cmod"
debug_malloc_pass(word=Pike_sp[0-1].u.string);
{
f_lower_case(1);
f_string_to_utf8(1);
f_Hyphenate_Hyphenate_low_hyphenate(1);
if(TYPEOF(Pike_sp[-1]) == T_STRING)
f_utf8_to_string(1);
}

}

#undef internal_init_Hyphenate_Hyphenate_defined
#define internal_init_Hyphenate_Hyphenate_defined

#undef Hyphenate_Hyphenate_event_handler_defined
#define Hyphenate_Hyphenate_event_handler_defined
static void init_Hyphenate_Hyphenate_struct(void)
#line 127 "hyphenate.cmod"
{
THIS->dict = NULL;
}


#undef Hyphenate_Hyphenate_gc_live_obj
#define Hyphenate_Hyphenate_gc_live_obj

#undef internal_exit_Hyphenate_Hyphenate_defined
#define internal_exit_Hyphenate_Hyphenate_defined

#undef Hyphenate_Hyphenate_event_handler_defined
#define Hyphenate_Hyphenate_event_handler_defined
static void exit_Hyphenate_Hyphenate_struct(void)
#line 132 "hyphenate.cmod"
{
HyphenDict * hd;
/*printf("end\n"); */
if(THIS && THIS->dict != NULL)
{
/*printf("freeing\n");     */
hd = THIS->dict;
/*printf("dict: %p\n", hd); */
hnj_hyphen_free(hd);
}
}


#ifdef Hyphenate_Hyphenate_event_handler_defined
static void Hyphenate_Hyphenate_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Hyphenate_Hyphenate_defined
  case PROG_EVENT_INIT: init_Hyphenate_Hyphenate_struct(); break;

#endif /* internal_init_Hyphenate_Hyphenate_defined */

#ifdef internal_exit_Hyphenate_Hyphenate_defined
  case PROG_EVENT_EXIT: exit_Hyphenate_Hyphenate_struct(); break;

#endif /* internal_exit_Hyphenate_Hyphenate_defined */
  default: break; 
  }
}

#endif /* Hyphenate_Hyphenate_event_handler_defined */
/*! @endclass
 */

/*! @endmodule
 */

/*! @endmodule
 */

/*! @endmodule
 */




#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
static int ___cmod_map_program_ids(int id)
{
  int i = 0;
  if( (id&0x7f000000) != 0x7f000000 ) return id;
  id = id&0x00ffffff;
#ifdef class_Hyphenate_Hyphenate_defined
if(id==2) return Hyphenate_Hyphenate_program->id;
#endif
  return 0;
}
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
PIKE_MODULE_INIT {

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( ___cmod_map_program_ids );

#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */

#ifdef class_Hyphenate_Hyphenate_defined

#ifdef PROG_HYPHENATE_HYPHENATE_ID
#line 21 "hyphenate.cmod"
  START_NEW_PROGRAM_ID(HYPHENATE_HYPHENATE);
#else
#line 21 "hyphenate.cmod"
  start_new_program();

#endif /* PROG_HYPHENATE_HYPHENATE_ID */
#line 21 "hyphenate.cmod"
  Hyphenate_Hyphenate_program = Pike_compiler->new_program;

#ifndef tObjImpl_HYPHENATE_HYPHENATE

#undef tObjIs_HYPHENATE_HYPHENATE
#define tObjIs_HYPHENATE_HYPHENATE "\3\1\177\0\0\2"

#undef tObjImpl_HYPHENATE_HYPHENATE
#define tObjImpl_HYPHENATE_HYPHENATE "\3\0\177\0\0\2"

#endif /* tObjImpl_HYPHENATE_HYPHENATE */

#ifdef THIS_HYPHENATE_HYPHENATE
  Hyphenate_Hyphenate_storage_offset = ADD_STORAGE(struct Hyphenate_Hyphenate_struct);
#endif /* THIS_HYPHENATE_HYPHENATE */

#ifdef Hyphenate_Hyphenate_event_handler_defined
  pike_set_prog_event_callback(Hyphenate_Hyphenate_event_handler);

#ifndef Hyphenate_Hyphenate_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Hyphenate_Hyphenate_gc_live_obj */

#endif /* Hyphenate_Hyphenate_event_handler_defined */

#ifdef f_Hyphenate_Hyphenate_create_defined

#ifdef f_Hyphenate_Hyphenate_create_fun_num_used
  f_Hyphenate_Hyphenate_create_fun_num =
#endif /* f_Hyphenate_Hyphenate_create_fun_num_used */
#line 30 "hyphenate.cmod"
    ADD_FUNCTION2("create", f_Hyphenate_Hyphenate_create, tFunc(tStr,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Hyphenate_Hyphenate_create_defined */

#ifdef f_Hyphenate_Hyphenate_low_hyphenate_defined

#ifdef f_Hyphenate_Hyphenate_low_hyphenate_fun_num_used
  f_Hyphenate_Hyphenate_low_hyphenate_fun_num =
#endif /* f_Hyphenate_Hyphenate_low_hyphenate_fun_num_used */
#line 48 "hyphenate.cmod"
    ADD_FUNCTION2("low_hyphenate", f_Hyphenate_Hyphenate_low_hyphenate, tFunc(tStr,tStr), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Hyphenate_Hyphenate_low_hyphenate_defined */

#ifdef f_Hyphenate_Hyphenate_hyphenate_defined

#ifdef f_Hyphenate_Hyphenate_hyphenate_fun_num_used
  f_Hyphenate_Hyphenate_hyphenate_fun_num =
#endif /* f_Hyphenate_Hyphenate_hyphenate_fun_num_used */
#line 117 "hyphenate.cmod"
    ADD_FUNCTION2("hyphenate", f_Hyphenate_Hyphenate_hyphenate, tFunc(tStr,tStr), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Hyphenate_Hyphenate_hyphenate_defined */
#line 21 "hyphenate.cmod"
  Hyphenate_Hyphenate_program=end_program();
#line 21 "hyphenate.cmod"
#ifdef Hyphenate_Hyphenate_program_fun_num_used
Hyphenate_Hyphenate_program_fun_num=
#endif
 add_program_constant("Hyphenate",Hyphenate_Hyphenate_program,0);

#endif /* class_Hyphenate_Hyphenate_defined */

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( 0 );
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
}
PIKE_MODULE_EXIT {

#ifdef class_Hyphenate_Hyphenate_defined
  if(Hyphenate_Hyphenate_program) {
#line 21 "hyphenate.cmod"
    free_program(Hyphenate_Hyphenate_program);
    Hyphenate_Hyphenate_program=0;
  }

#endif /* class_Hyphenate_Hyphenate_defined */
}


gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University