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>
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$";
20 #include <zephyr/mit-copyright.h>
22 #include "new_memory.h"
23 #include "text_operations.h"
24 #include "char_stack.h"
27 lany(string *text_ptr,
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;
44 lbreak(string *text_ptr,
45 const character_class 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;
61 lspan(string *text_ptr,
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;
78 rany(string *text_ptr,
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;
96 rbreak(string *text_ptr,
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;
114 rspan(string *text_ptr,
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;