1*b5514887Smuffin /* 2*b5514887Smuffin * Copyright 1991 Sun Microsystems, Inc. All rights reserved. 3*b5514887Smuffin * Use is subject to license terms. 4*b5514887Smuffin */ 5*b5514887Smuffin 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 15*b5514887Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate /* tm.c: split numerical fields */ 187c478bd9Sstevel@tonic-gate # include "t..c" 19*b5514887Smuffin 207c478bd9Sstevel@tonic-gate char * 21*b5514887Smuffin maknew(char *str) 227c478bd9Sstevel@tonic-gate { 237c478bd9Sstevel@tonic-gate /* make two numerical fields */ 247c478bd9Sstevel@tonic-gate int c; 257c478bd9Sstevel@tonic-gate char *dpoint, *p, *q, *ba; 267c478bd9Sstevel@tonic-gate p = str; 277c478bd9Sstevel@tonic-gate for (ba= 0; c = *str; str++) 287c478bd9Sstevel@tonic-gate if (c == '\\' && *(str+1)== '&') 297c478bd9Sstevel@tonic-gate ba=str; 307c478bd9Sstevel@tonic-gate str=p; 317c478bd9Sstevel@tonic-gate if (ba==0) 327c478bd9Sstevel@tonic-gate { 337c478bd9Sstevel@tonic-gate for (dpoint=0; *str; str++) 347c478bd9Sstevel@tonic-gate { 357c478bd9Sstevel@tonic-gate if (*str=='.' && !ineqn(str,p) && 367c478bd9Sstevel@tonic-gate (str>p && digit(*(str-1)) || 377c478bd9Sstevel@tonic-gate digit(*(str+1)))) 387c478bd9Sstevel@tonic-gate dpoint=str; 397c478bd9Sstevel@tonic-gate } 407c478bd9Sstevel@tonic-gate if (dpoint==0) 417c478bd9Sstevel@tonic-gate for(; str>p; str--) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate if (digit( * (str-1) ) && !ineqn(str, p)) 447c478bd9Sstevel@tonic-gate break; 457c478bd9Sstevel@tonic-gate } 467c478bd9Sstevel@tonic-gate if (!dpoint && p==str) /* not numerical, don't split */ 477c478bd9Sstevel@tonic-gate return(0); 487c478bd9Sstevel@tonic-gate if (dpoint) str=dpoint; 497c478bd9Sstevel@tonic-gate } 507c478bd9Sstevel@tonic-gate else 517c478bd9Sstevel@tonic-gate str = ba; 527c478bd9Sstevel@tonic-gate p =str; 537c478bd9Sstevel@tonic-gate if (exstore ==0 || exstore >exlim) 547c478bd9Sstevel@tonic-gate { 557c478bd9Sstevel@tonic-gate exstore = chspace(); 567c478bd9Sstevel@tonic-gate exlim= exstore+MAXCHS; 577c478bd9Sstevel@tonic-gate } 587c478bd9Sstevel@tonic-gate q = exstore; 597c478bd9Sstevel@tonic-gate ba = exstore + MAXSTR; 607c478bd9Sstevel@tonic-gate do { 617c478bd9Sstevel@tonic-gate if (exstore > ba) 627c478bd9Sstevel@tonic-gate error(gettext("numeric field too big")); 637c478bd9Sstevel@tonic-gate } while (*exstore++ = *str++); 647c478bd9Sstevel@tonic-gate *p = 0; 657c478bd9Sstevel@tonic-gate return(q); 667c478bd9Sstevel@tonic-gate } 67*b5514887Smuffin 68*b5514887Smuffin int 69*b5514887Smuffin ineqn (char *s, char *p) 707c478bd9Sstevel@tonic-gate { 717c478bd9Sstevel@tonic-gate /* true if s is in a eqn within p */ 727c478bd9Sstevel@tonic-gate int ineq = 0, c; 737c478bd9Sstevel@tonic-gate while (c = *p) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate if (s == p) 767c478bd9Sstevel@tonic-gate return(ineq); 777c478bd9Sstevel@tonic-gate p++; 787c478bd9Sstevel@tonic-gate if ((ineq == 0) && (c == delim1)) 797c478bd9Sstevel@tonic-gate ineq = 1; 807c478bd9Sstevel@tonic-gate else 817c478bd9Sstevel@tonic-gate if ((ineq == 1) && (c == delim2)) 827c478bd9Sstevel@tonic-gate ineq = 0; 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate return(0); 857c478bd9Sstevel@tonic-gate } 86