🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Eric Gisin Fri, 08 Feb 1991 20:35
ed s/a*/./g description
#761
Author: Eric Gisin
Date: Fri, 08 Feb 1991 20:35
25 lines
1193 bytes
Submitted-by: eric@mks.com (Eric Gisin)

Does anyone have an complete description of how s///g and awk's gsub
handle the special case of an empty pattern match?
The System V documents and POSIX.2 don't cover this.

For example, the command s/[a-z]*/./g does the following on System V ed:
	-bug-	becomes .-.-.
The following algorithm produces an extra dot:
	-bug-	becomes	.-..-.

gsub(pattern, replace, src, dst)
	while (1) {
		find next pattern in src
		copy part before match from src to dst
		copy replace to dst
		advance src to end of match
		if (at end of src)	break;
		/* special case for empty match */
		if (match was empty)
			*dst++ = *src++;
	}


Volume-Number: Volume 22, Number 118
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads