Back to index

tetex-bin  3.0
extra_routines.c
Go to the documentation of this file.
00001 /* extra_routines.c: Tables for glues, rules, penalties, etc.
00002 
00003 This file is part of Omega,
00004 which is based on the web2c distribution of TeX,
00005 
00006 Copyright (c) 1994--2001 John Plaice and Yannis Haralambous
00007 
00008 Omega is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2 of the License, or
00011 (at your option) any later version.
00012 
00013 Omega is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Omega; if not, write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00021 
00022 */
00023 
00024 #include "cpascal.h"
00025 #include "manifests.h"
00026 #include "list_routines.h"
00027 #include "extra_routines.h"
00028 #include "header_routines.h"
00029 #include "error_routines.h"
00030 
00031 #define MAX_EXTRA_TABLES 16
00032 #define MAX_TABLE_ENTRIES 256
00033 
00034 unsigned *ivalue_tables[MAX_EXTRA_TABLES];
00035 unsigned *penalty_tables[MAX_EXTRA_TABLES];
00036 fix      *fvalue_tables[MAX_EXTRA_TABLES];
00037 fix      *mvalue_tables[MAX_EXTRA_TABLES];
00038 rule     *rule_tables[MAX_EXTRA_TABLES];
00039 glue     *glue_tables[MAX_EXTRA_TABLES];
00040 
00041 unsigned max_ivalue_entry[MAX_EXTRA_TABLES];
00042 unsigned max_penalty_entry[MAX_EXTRA_TABLES];
00043 unsigned max_fvalue_entry[MAX_EXTRA_TABLES];
00044 unsigned max_mvalue_entry[MAX_EXTRA_TABLES];
00045 unsigned max_rule_entry[MAX_EXTRA_TABLES];
00046 unsigned max_glue_entry[MAX_EXTRA_TABLES];
00047 
00048 unsigned no_ivalue_tables = 0;
00049 unsigned no_penalty_tables = 0;
00050 unsigned no_fvalue_tables = 0;
00051 unsigned no_mvalue_tables = 0;
00052 unsigned no_rule_tables = 0;
00053 unsigned no_glue_tables = 0;
00054 
00055 unsigned *cur_ivalue_table;
00056 unsigned *cur_penalty_table;
00057 fix      *cur_mvalue_table;
00058 fix      *cur_fvalue_table;
00059 rule     *cur_rule_table;
00060 glue     *cur_glue_table;
00061 
00062 unsigned cur_ivalue_table_index;
00063 unsigned cur_penalty_table_index;
00064 unsigned cur_mvalue_table_index;
00065 unsigned cur_fvalue_table_index;
00066 unsigned cur_rule_table_index;
00067 unsigned cur_glue_table_index;
00068 
00069 unsigned *cur_ivalue_entry;
00070 unsigned *cur_penalty_entry;
00071 fix      *cur_mvalue_entry;
00072 fix      *cur_fvalue_entry;
00073 rule     *cur_rule_entry;
00074 glue     *cur_glue_entry;
00075 
00076 unsigned nki=0;
00077 unsigned nwi=0;
00078 unsigned nkp=0;
00079 unsigned nwp=0;
00080 unsigned nkm=0;
00081 unsigned nwm=0;
00082 unsigned nkf=0;
00083 unsigned nwf=0;
00084 unsigned nkr=0;
00085 unsigned nwr=0;
00086 unsigned nkg=0;
00087 unsigned nwg=0;
00088 
00089 void
00090 compute_ofm_extra_stuff(void)
00091 {
00092     unsigned i=0;
00093 
00094     if (ofm_level >= OFM_LEVEL1) {
00095         nki = no_ivalue_tables;
00096         nkp = no_penalty_tables;
00097         nkm = no_mvalue_tables;
00098         nkf = no_fvalue_tables;
00099         nkr = no_rule_tables;
00100         nkg = no_glue_tables;
00101         for (i=0; i<nki; i++) {
00102             nwi += max_ivalue_entry[i];
00103         }
00104         for (i=0; i<nkp; i++) {
00105             nwp += max_penalty_entry[i];
00106         }
00107         for (i=0; i<nkm; i++) {
00108             nwm += max_mvalue_entry[i];
00109         }
00110         for (i=0; i<nkf; i++) {
00111             nwf += max_fvalue_entry[i];
00112         }
00113         for (i=0; i<nkr; i++) {
00114             nwr += 3 * max_rule_entry[i];
00115         }
00116         for (i=0; i<nkg; i++) {
00117             nwg += 4 * max_glue_entry[i];
00118         }
00119     }
00120 }
00121 
00122 void
00123 output_ofm_extra_stuff(void)
00124 {
00125     if (ofm_level >= OFM_LEVEL1) {
00126         fatal_error_0("OFM level 1 not currently supported");
00127     }
00128 }
00129 
00130 void
00131 init_all_tables(void)
00132 {
00133      unsigned i=0;
00134 
00135      for (i=0; i<MAX_EXTRA_TABLES; i++) {
00136          ivalue_tables[i] = NULL;
00137          penalty_tables[i] = NULL;
00138          fvalue_tables[i] = NULL;
00139          mvalue_tables[i] = NULL;
00140          rule_tables[i] = NULL;
00141          glue_tables[i] = NULL;
00142      }
00143 }
00144 
00145 void
00146 init_font_ivalue(unsigned tab)
00147 {
00148      unsigned j;
00149 
00150      if (tab>=MAX_EXTRA_TABLES)
00151          internal_error_1("init_font_ivalue (tab=%d)", tab);
00152      if (ivalue_tables[tab] != NULL) {
00153          warning_1("IVALUE table (D %d) previously defined; "
00154                    "old value ignored", tab);
00155          cur_ivalue_table = ivalue_tables[tab];
00156          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00157               cur_ivalue_table[j] = 0;
00158          }
00159      } else {
00160          no_ivalue_tables++;
00161          ivalue_tables[tab] =
00162              (unsigned *) xmalloc(MAX_TABLE_ENTRIES*sizeof(unsigned));
00163          cur_ivalue_table = ivalue_tables[tab];
00164      }
00165      max_ivalue_entry[tab] = 0;
00166 }
00167 
00168 void
00169 init_font_penalty(unsigned tab)
00170 {
00171      unsigned j;
00172 
00173      if (tab>=MAX_EXTRA_TABLES)
00174          internal_error_1("init_font_penalty (tab=%d)", tab);
00175      if (penalty_tables[tab] != NULL) {
00176          warning_1("IVALUE table (D %d) previously defined; "
00177                    "old value ignored", tab);
00178          cur_penalty_table = ivalue_tables[tab];
00179          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00180               cur_penalty_table[j] = 0;
00181          }
00182      } else {
00183          no_penalty_tables++;
00184          penalty_tables[tab] =
00185              (unsigned *) xmalloc(MAX_TABLE_ENTRIES*sizeof(unsigned));
00186          cur_penalty_table = ivalue_tables[tab];
00187      }
00188      max_penalty_entry[tab] = 0;
00189 }
00190 
00191 void
00192 init_font_mvalue(unsigned tab)
00193 {
00194      unsigned j;
00195 
00196      if (tab>=MAX_EXTRA_TABLES)
00197          internal_error_1("init_font_mvalue (tab=%d)", tab);
00198      if (mvalue_tables[tab] != NULL) {
00199          warning_1("MVALUE table (D %d) previously defined; "
00200                    "old value ignored", tab);
00201          cur_mvalue_table = mvalue_tables[tab];
00202          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00203               cur_mvalue_table[j] = 0;
00204          }
00205      } else {
00206          no_mvalue_tables++;
00207          mvalue_tables[tab] =
00208              (fix *) xmalloc(MAX_TABLE_ENTRIES*sizeof(unsigned));
00209          cur_mvalue_table = mvalue_tables[tab];
00210      }
00211      max_mvalue_entry[tab] = 0;
00212 }
00213 
00214 void
00215 init_font_fvalue(unsigned tab)
00216 {
00217      unsigned j;
00218 
00219      if (tab>=MAX_EXTRA_TABLES)
00220          internal_error_1("init_font_fvalue (tab=%d)", tab);
00221      if (fvalue_tables[tab] != NULL) {
00222          warning_1("FVALUE table (D %d) previously defined; "
00223                    "old value ignored", tab);
00224          cur_fvalue_table = fvalue_tables[tab];
00225          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00226               cur_fvalue_table[j] = 0;
00227          }
00228      } else {
00229          no_fvalue_tables++;
00230          fvalue_tables[tab] =
00231              (fix *) xmalloc(MAX_TABLE_ENTRIES*sizeof(unsigned));
00232          cur_fvalue_table = fvalue_tables[tab];
00233      }
00234      max_fvalue_entry[tab] = 0;
00235 }
00236 
00237 void
00238 init_font_rule(unsigned tab)
00239 {
00240      unsigned j;
00241 
00242      if (tab>=MAX_EXTRA_TABLES)
00243          internal_error_1("init_font_rule (tab=%d)", tab);
00244      if (rule_tables[tab] != NULL) {
00245          warning_1("RULE table (D %d) previously defined; "
00246                    "old value ignored", tab);
00247          cur_rule_table = rule_tables[tab];
00248          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00249               cur_rule_table[j].rule_wd = 0;
00250               cur_rule_table[j].rule_dp = 0;
00251               cur_rule_table[j].rule_ht = 0;
00252          }
00253      } else {
00254          no_rule_tables++;
00255          rule_tables[tab] =
00256              (rule *) xmalloc(MAX_TABLE_ENTRIES*sizeof(rule));
00257          cur_rule_table = rule_tables[tab];
00258      }
00259      max_rule_entry[tab] = 0;
00260 }
00261 
00262 void
00263 init_font_glue(unsigned tab)
00264 {
00265      unsigned j;
00266 
00267      if (tab>=MAX_EXTRA_TABLES)
00268          internal_error_1("init_font_glue (tab=%d)", tab);
00269      if (glue_tables[tab] != NULL) {
00270          warning_1("GLUE table (D %d) previously defined; "
00271                    "old value ignored", tab);
00272          cur_glue_table = glue_tables[tab];
00273          for (j=0; j<MAX_TABLE_ENTRIES; j++) {
00274               cur_glue_table[j].glue_width = 0;
00275               cur_glue_table[j].glue_stretch = 0;
00276               cur_glue_table[j].glue_shrink = 0;
00277               cur_glue_table[j].glue_stretch_order = 0;
00278               cur_glue_table[j].glue_shrink_order = 0;
00279               cur_glue_table[j].glue_type = 0;
00280               cur_glue_table[j].glue_arg_type = GLUEARG_NONE;
00281               cur_glue_table[j].glue_arg1 = 0;
00282               cur_glue_table[j].glue_arg2 = 0;
00283          }
00284      } else {
00285          no_glue_tables++;
00286          glue_tables[tab] =
00287              (glue *) xmalloc(MAX_TABLE_ENTRIES*sizeof(glue));
00288          cur_glue_table = glue_tables[tab];
00289      }
00290      max_glue_entry[tab] = 0;
00291 }
00292 
00293 
00294 void
00295 init_font_ivalue_entry(unsigned index)
00296 {
00297      if (index>=MAX_TABLE_ENTRIES)
00298          internal_error_1("init_font_ivalue_entry (index=%d)", index);
00299      cur_ivalue_entry = &cur_ivalue_table[index];
00300      if (max_ivalue_entry[cur_ivalue_table_index]<index)
00301          max_ivalue_entry[cur_ivalue_table_index] = index;
00302 }
00303 
00304 void
00305 init_font_penalty_entry(unsigned index)
00306 {
00307      if (index>=MAX_TABLE_ENTRIES)
00308          internal_error_1("init_font_penalty_entry (index=%d)", index);
00309      cur_penalty_entry = &cur_penalty_table[index];
00310      if (max_penalty_entry[cur_penalty_table_index]<index)
00311          max_penalty_entry[cur_penalty_table_index] = index;
00312 }
00313 
00314 void
00315 init_font_mvalue_entry(unsigned index)
00316 {
00317      if (index>=MAX_TABLE_ENTRIES)
00318          internal_error_1("init_font_mvalue_entry (index=%d)", index);
00319      cur_mvalue_entry = &cur_mvalue_table[index];
00320      if (max_mvalue_entry[cur_mvalue_table_index]<index)
00321          max_mvalue_entry[cur_mvalue_table_index] = index;
00322 }
00323 
00324 void
00325 init_font_fvalue_entry(unsigned index)
00326 {
00327      if (index>=MAX_TABLE_ENTRIES)
00328          internal_error_1("init_font_fvalue_entry (index=%d)", index);
00329      cur_fvalue_entry = &cur_fvalue_table[index];
00330      if (max_fvalue_entry[cur_fvalue_table_index]<index)
00331          max_fvalue_entry[cur_fvalue_table_index] = index;
00332 }
00333 
00334 void
00335 init_font_rule_entry(unsigned index)
00336 {
00337      if (index>=MAX_TABLE_ENTRIES)
00338          internal_error_1("init_font_rule_entry (index=%d)", index);
00339      cur_rule_entry = &cur_rule_table[index];
00340      if (max_rule_entry[cur_rule_table_index]<index)
00341          max_rule_entry[cur_rule_table_index] = index;
00342 }
00343 
00344 void
00345 init_font_glue_entry(unsigned index)
00346 {
00347      if (index>=MAX_TABLE_ENTRIES)
00348          internal_error_1("init_font_glue_entry (index=%d)", index);
00349      cur_glue_entry = &cur_glue_table[index];
00350      if (max_glue_entry[cur_glue_table_index]<index)
00351          max_glue_entry[cur_glue_table_index] = index;
00352 }
00353 
00354 
00355 void
00356 set_font_ivalue_definition(unsigned val)
00357 {
00358      *cur_ivalue_entry = val;
00359 }
00360 
00361 void
00362 set_font_penalty_definition(unsigned val)
00363 {
00364      *cur_penalty_entry = val;
00365 }
00366 
00367 void
00368 set_font_mvalue_definition(fix fval)
00369 {
00370      *cur_mvalue_entry = fval;
00371 }
00372 
00373 void
00374 set_font_fvalue_definition(fix fval)
00375 {
00376      *cur_fvalue_entry = fval;
00377 }
00378 
00379 void
00380 set_font_rule_measure(unsigned measure, fix fval)
00381 {
00382      switch (measure) {
00383          case RULE_WD: {
00384              cur_rule_entry->rule_wd = fval; break;
00385          }
00386          case RULE_HT: {
00387              cur_rule_entry->rule_ht = fval; break;
00388          }
00389          case RULE_DP: {
00390              cur_rule_entry->rule_dp = fval; break;
00391          }
00392          default: {
00393              internal_error_1("set_font_rule_measure (measure=%d)", measure);
00394          }
00395      }
00396 }
00397 
00398 
00399 void
00400 set_font_glue_width(fix width)
00401 {
00402      cur_glue_entry->glue_width = width;
00403 }
00404 
00405 void
00406 set_font_glue_shrink_stretch(unsigned shrink_stretch,
00407                              fix width, unsigned order)
00408 {
00409      switch (shrink_stretch) {
00410          case GLUE_SHRINK: {
00411              cur_glue_entry->glue_shrink = width; break;
00412              cur_glue_entry->glue_shrink_order = order; break;
00413          }
00414          case GLUE_STRETCH: {
00415              cur_glue_entry->glue_stretch_order = order; break;
00416          }
00417          default: {
00418              internal_error_1("set_font_rule_measure (shrink_stretch=%d)",
00419                               shrink_stretch);
00420          }
00421      }
00422 }
00423 
00424 void
00425 set_font_glue_type(unsigned type)
00426 {
00427      cur_glue_entry->glue_type = type;
00428 }
00429 
00430 void
00431 set_font_glue_character(unsigned c)
00432 {
00433     cur_glue_entry->glue_arg_type = GLUEARG_CHAR;
00434     cur_glue_entry->glue_arg1 = c;
00435 }
00436 
00437 void
00438 set_font_glue_rule(unsigned rule_table, unsigned rule_index)
00439 {
00440     cur_glue_entry->glue_arg_type = GLUEARG_RULE;
00441     cur_glue_entry->glue_arg1 = rule_table;
00442     cur_glue_entry->glue_arg2 = rule_index;
00443 }
00444 
00445 void
00446 set_character_ivalue(unsigned table, unsigned index)
00447 {
00448     fatal_error_0("CHARIVALUE not currently supported");
00449 }
00450 
00451 void
00452 set_character_penalty(unsigned table, unsigned index)
00453 {
00454     fatal_error_0("CHARPENALTY not currently supported");
00455 }
00456 
00457 void
00458 set_character_mvalue(unsigned table, unsigned index)
00459 {
00460     fatal_error_0("CHARMVALUE not currently supported");
00461 }
00462 
00463 void
00464 set_character_fvalue(unsigned table, unsigned index)
00465 {
00466     fatal_error_0("CHARFVALUE not currently supported");
00467 }
00468 
00469 void
00470 set_character_rule(unsigned table, unsigned index)
00471 {
00472     fatal_error_0("CHARRULE not currently supported");
00473 }
00474 
00475 void
00476 set_character_glue(unsigned table, unsigned index)
00477 {
00478     fatal_error_0("CHARGLUE not currently supported");
00479 }