1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It is one of the source files comprising zwgc, the Zephyr WindowGram
5 * Created by: Marc Horowitz <marc@athena.mit.edu>
7 * $Id: text_operations.c,v 1.6 1999/01/22 23:20:39 ghudson Exp $
9 * Copyright (c) 1989 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
16 #if (!defined(lint) && !defined(SABER))
17 static const char rcsid_text_operations_c[] = "$Id: text_operations.c,v 1.6 1999/01/22 23:20:39 ghudson Exp $";
20 #include <zephyr/mit-copyright.h>
22 #include "new_memory.h"
23 #include "text_operations.h"
24 #include "char_stack.h"
26 string lany(text_ptr, str)
30 string result, whats_left;
33 while (*p && *str) p++, str++;
35 result = string_CreateFromData(*text_ptr, p - *text_ptr);
36 whats_left = string_Copy(p);
38 *text_ptr = whats_left;
43 string lbreak(text_ptr, set)
47 string result, whats_left;
50 while (*p && !set[*p]) p++;
52 result = string_CreateFromData(*text_ptr, p - *text_ptr);
53 whats_left = string_Copy(p);
55 *text_ptr = whats_left;
60 string lspan(text_ptr, set)
64 string result, whats_left;
67 while (*p && set[*p]) p++;
69 result = string_CreateFromData(*text_ptr, p - *text_ptr);
70 whats_left = string_Copy(p);
72 *text_ptr = whats_left;
77 string rany(text_ptr, str)
81 string result, whats_left;
82 string text = *text_ptr;
83 char *p = text + strlen(text);
85 while (text<p && *str) p--, str++;
87 result = string_Copy(p);
88 whats_left = string_CreateFromData(text, p - text);
90 *text_ptr = whats_left;
95 string rbreak(text_ptr, set)
99 string result, whats_left;
100 string text = *text_ptr;
101 char *p = text + strlen(text);
103 while (text<p && !set[p[-1]]) p--;
105 result = string_Copy(p);
106 whats_left = string_CreateFromData(text, p - text);
108 *text_ptr = whats_left;
113 string rspan(text_ptr, set)
117 string result, whats_left;
118 string text = *text_ptr;
119 char *p = text + strlen(text);
121 while (text<p && set[p[-1]]) p--;
123 result = string_Copy(p);
124 whats_left = string_CreateFromData(text, p - text);
126 *text_ptr = whats_left;