1############################################################################## 2# Copyright 2020,2022 Thomas E. Dickey # 3# # 4# Permission is hereby granted, free of charge, to any person obtaining a # 5# copy of this software and associated documentation files (the "Software"), # 6# to deal in the Software without restriction, including without limitation # 7# the rights to use, copy, modify, merge, publish, distribute, distribute # 8# with modifications, sublicense, and/or sell copies of the Software, and to # 9# permit persons to whom the Software is furnished to do so, subject to the # 10# following conditions: # 11# # 12# The above copyright notice and this permission notice shall be included in # 13# all copies or substantial portions of the Software. # 14# # 15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # 16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # 17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # 18# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # 19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # 20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # 21# DEALINGS IN THE SOFTWARE. # 22# # 23# Except as contained in this notice, the name(s) of the above copyright # 24# holders shall not be used in advertising or otherwise to promote the sale, # 25# use or other dealings in this Software without prior written # 26# authorization. # 27############################################################################## 28# 29# Author: Thomas E. Dickey 30# 31# $Id: split-path.awk,v 1.4 2022/11/26 23:46:20 tom Exp $ 32BEGIN { cols = 72; } 33/[$]THIS_DATADIR/ { 34 if (substr(this_datadir, length(this_datadir)) != "/") 35 this_datadir = this_datadir "/"; 36 gsub("[$]THIS_DATADIR", "\"" this_datadir "\""); 37 if ( length ($0) > cols ) { 38 indent = index($0, "\"") - 1; 39 broken = index($0, "&"); 40 if (broken > 0 && broken < indent) 41 indent = broken - 1; 42 leader = sprintf ("%*s& ", indent, " "); 43 buffer = $0; 44 first = 1; 45 while ( length(buffer) > cols ) { 46 printf("%.*s\"\n", cols, buffer); 47 buffer = leader "\"" substr(buffer, cols + 1); 48 } 49 if ( buffer != "" && buffer != leader "\"\"" ) 50 printf("%.*s\n", cols, buffer); 51 next; 52 } 53} 54{ 55 print; 56} 57