Roxen.git / server / modules / misc / randomtext.pike

version» Context lines:

Roxen.git/server/modules/misc/randomtext.pike:1: + // This is a roxen module. Copyright © 2000 - 2009, Roxen IS. +    // randomtext.pike -- random text generator module   //   // By Leif Stensson.   //   // This is a Roxen module for generating semi-random text based on   // a set of rules. The functionality is available through a tag   //   // <make-random-text rules="NAME_OF_RULE_FILE" />   //   // Normally, the module will first look in its cache to see if a
Roxen.git/server/modules/misc/randomtext.pike:51:   // called.   //   // ... any yes, this module was a quick hack for amusement and for   // use in some courses to help provide dummy contents for new sites,   // so don't use this as a model for how to write Roxen modules.      inherit "module";      #include <module.h>    - string version = "$Id: randomtext.pike,v 1.6 2001/05/04 13:54:24 leif Exp $"; + string version = "$Id$";      constant module_type = MODULE_TAG;   constant module_name = "Random Text";   constant module_doc =    "This module provides a simple way of generating texts on a "    "semi-random basis according to a set of rules. Apart from its "    "amusement value, this can be useful for testing and educational "    "purposes, such as generating small quiz pages or producing "    "many different kinds of input for testing text processing tags.";   
Roxen.git/server/modules/misc/randomtext.pike:124:   {    int period = 60*query("flushcache");       call_out(flush_cache, period < 5 ? 5 : period);       searchpath = query("searchpath");    if (stringp(searchpath) && searchpath[-1] == '/')    searchpath = searchpath[0..sizeof(searchpath)-2];   }    - static int isalnum(string c) + protected int isalnum(string c)   {    if (!stringp(c) || sizeof(c) != 1)    return 0;    if (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9")    return 1;    return 0;   }    - static int isidchar(string c) + protected int isidchar(string c)    { return isalnum(c) || c == "-" || c == "_";}    - static int isopchar(string c) + protected int isopchar(string c)    { return (< "+", "-", "*", "/", "%", "!", "=", "<", ">" >)[c];}      mixed evalexpr(string expr, mapping args)   //   // Evaluate a simple expression. Note: this function doesn't care   // about traditional operator precedence -- binary operators are   // always applied from right to left.   //   {    string left, op, right; mixed value, value2;
Roxen.git/server/modules/misc/randomtext.pike:399:    if (sections[sec]["assign"])    args[sections[sec]["assign"]] = text;       if (sections[sec]["single-shot"])    sections[sec]["result"] = text;       return text;   }      string rtt_read(string path) - { int lineno = 0; string line, mode = 0, tmp; + { int lineno = 0; string line, mode = 0;    mapping sections = ([ "steps": 0 ]);    string this_section = "***";    int secindex = -1;       if (Stdio.file_size(path) < 0)    return "<b>error: unable to access rule file</b>";       object f = Stdio.FILE(path, "r");    if (!f) return "<b>Error: no rule file found for '" + path + "'</b>";