Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
e970abf6
Kaydet (Commit)
e970abf6
authored
Ara 23, 2010
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
move add mode-lines in here
üst
6cf8eb37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
0 deletions
+174
-0
add-modelines
solenv/bin/add-modelines
+174
-0
No files found.
solenv/bin/add-modelines
0 → 100644
Dosyayı görüntüle @
e970abf6
#!/bin/bash
# add-modelines, a simple script to add comments to
# the beginning and end of source files for LibreOffice devs
# Blame goes to Jesse Adelman (at least at first)
# someone AT boldandbusted dotty-dot com
# http://www.boldandbusted.com/
# (c) 2010 Bold and Busted LLC
# Licensed under the MPL/LGPLv3 or later
# First edit 2010-10-08
# Updated on 2010-10-09
# Version 0.7
# NOTE: At present, this script only works for files with C-like comments.
# NOTE: If you don't specify -p, the script will act on the current working directory.
# NOTE: If no arguments are specified, the defitions below are in effect.
# TO DO
# - Deuglifiy?
# - Make source file type agnostic modelines?
# - Too many/too few comments?
# - Handle top level source directories with whitespace names? (Do they exist?)
# Turn off globbing, helps with SourceFiles
set
-f
# POSIX
set
-o
posix
# Change these to taste
FirstLine
=
'/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */'
LastLine
=
'/* vim:set shiftwidth=4 softtabstop=4 expandtab: */'
SourceFiles
=
'*.cxx *.cpp *.hxx *.hpp *.c *.h'
# Set defaults (don't change these)
ModelineReplace
=
"false"
# Functions
function
SetEnvironment
()
{
if
[
-n
"
$(
which
tail
)
"
-a
-n
"
$(
which
head
)
"
]
;
then
{
headCMD
=
`
which
head
`
tailCMD
=
`
which
tail
`
}
else
{
echo
"Missing head or tail, exiting..."
exit
1
}
fi
if
[
-n
"
$(
which find
)
"
]
;
then
findCMD
=
`
which find
`
else
{
echo
"Missing find, exiting..."
exit
1
}
fi
if
[
-n
"
$(
which
awk
)
"
]
;
then
awkCMD
=
`
which
awk
`
else
{
echo
"Missing awk, exiting..."
exit
1
}
fi
}
function
EditFile
()
{
local
FileToEdit
local
currentFirstLine
local
currentLastLine
FileToEdit
=
"
$1
"
currentFirstLine
=
`
$headCMD
-1
"
$FileToEdit
"
`
currentLastLine
=
`
$tailCMD
-1
"
$FileToEdit
"
`
case
"
$ModelineReplace
"
in
"true"
)
if
[
"
${
currentFirstLIne
:0:6
}
"
=
"
${
FirstLine
:0:6
}
"
]
;
then
{
echo
"
$FirstLine
"
>
"
$FileToEdit
"
.new
$tailCMD
-n
+2
"
$FileToEdit
"
>>
"
$FileToEdit
"
.new
}
fi
if
[
-e
"
$FileToEdit
.new"
]
;
then
{
echo
"
$LastLine
"
>>
"
$FileToEdit
"
.new
}
fi
if
[
"
${
currentLastLine
:0:6
}
"
=
"
${
LastLine
:0:6
}
"
]
;
then
{
$headCMD
-n
-1
"
$FileToEdit
"
>
"
$FileToEdit
"
.new
echo
"
$LastLine
"
>>
"
$FileToEdit
"
.new
}
fi
mv
"
$FileToEdit
"
.new
"
$FileToEdit
"
echo
"
$FileToEdit
updated"
;;
"false"
)
if
[
"
${
currentFirstLine
:0:6
}
"
!=
"
${
FirstLine
:0:6
}
"
]
;
then
if
[
"
${
currentLastLine
:0:6
}
"
!=
"
${
LastLine
:0:6
}
"
]
;
then
{
echo
"
$FirstLine
"
>
"
$FileToEdit
"
.new
cat
"
$FileToEdit
"
>>
"
$FileToEdit
"
.new
if
[
"x
${
currentLastLine
}
"
!=
"x"
]
;
then
echo
""
>>
"
$FileToEdit
"
.new
fi
echo
"
$LastLine
"
>>
"
$FileToEdit
"
.new
mv
"
$FileToEdit
"
.new
"
$FileToEdit
"
echo
"
$FileToEdit
updated"
}
fi
fi
;;
esac
}
function
PrintUsage
()
{
echo
"Usage:
$0
[-z] [-s
\"
<sourcefile glob>
\"
] [-p <path to source>]"
}
# Main
SetEnvironment
# Get command line options
while
getopts
"zs:p:"
opt
;
do
case
$opt
in
z
)
ModelineReplace
=
"true"
;;
s
)
SourceFiles
=
"
$OPTARG
"
;;
p
)
findPath
=
"
$OPTARG
"
;;
*
)
PrintUsage
exit
1
;;
esac
done
if
[
$OPTIND
-gt
1
]
;
then
shift
$((
$OPTIND
-
1
))
fi
if
[
$#
-gt
1
]
;
then
{
PrintUsage
echo
"Remember to quote the source file globs after -s"
exit
1
}
fi
# Create GNU find expressions that traverse the filesystem once and only once
if
[
-z
"
$findPath
"
]
;
then
findArgs
=
'.'
else
findArgs
=
"
$findPath
"
fi
for
FileType
in
${
SourceFiles
}
;
do
findArgs
=
"
$findArgs
"
' ( -iname '
"
$FileType
"
' -print ) , '
done
# This gets rid of the final " , " in the find argument list
findArgs
=
"
${
findArgs
:0:
(
${#
findArgs
}
-2)
}
"
for
file
in
$(
$findCMD
$findArgs
)
;
do
EditFile
"
$file
"
echo
"Completed: "
"
$file
"
done
# vim:set shiftwidth=4 softtabstop=4 expandtab:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment