zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] remove sed from _ffmpeg
@ 2010-09-16  8:38 Baptiste Daroussin
  2010-09-16  9:03 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Baptiste Daroussin @ 2010-09-16  8:38 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 131 bytes --]

Hi,

Here is a patch to remove sed from _ffmpeg.

There still have the perl to be removed but let's see that later.

Regards,
Bapt

[-- Attachment #1.2: _ffmpeg_no_sed.diff --]
[-- Type: text/x-diff, Size: 1978 bytes --]

diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg
index 7c0660e..7413fea 100644
--- a/Completion/Unix/Command/_ffmpeg
+++ b/Completion/Unix/Command/_ffmpeg
@@ -18,24 +18,24 @@ _ffmpeg_presets() {
 
 _ffmpeg_acodecs() {
     local acodecs
-    acodecs=($(ffmpeg -codecs 2>/dev/null | sed -n '/^ .[E ]A/ {s/^ .......//; s/ .*//p;}'))
+    acodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _ffmpeg_compadd 'force audio codec (''copy'' to copy stream)' acodecs ''
 }
 
 _ffmpeg_vcodecs() {
     local vcodecs
-    vcodecs=($(ffmpeg -codecs 2>/dev/null | sed -n '/^ .[E ]V/ {s/^ .......//; s/ .*//p;}'))
+    vcodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _ffmpeg_compadd 'force video codec (''copy'' to copy stream)' vcodecs ''
 }
 
 _ffmpeg_formats() {
     local formats
-    formats=($(ffmpeg -formats 2>/dev/null | sed -e '1,/--/d' -e 's/^....//' -e 's/ .*//' | tr , '\n' | sort | uniq))
+    ${(ou)${=${(s:,:)${${(M)${(f)"$(ffmpeg -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}}
     _ffmpeg_compadd 'force format' formats ''
 }
 
 _ffmpeg_list_pix_fmts() {
-    ffmpeg -pix_fmts 2>/dev/null | sed -e '1,/-----/d' -e 's/^......//' -e 's/ .*//'
+    print -l ${${(M)${(f)"$(ffmpeg -pix_fmts 2>/dev/null)"}:#[I.]*}//(#b)??????([^[:space:]]##)*/$match[1]}
 }
 
 _ffmpeg_pix_fmts() {
@@ -46,7 +46,7 @@ _ffmpeg_pix_fmts() {
 
 _ffmpeg_bsfs() {
     local bsfs
-    bsfs=($(ffmpeg -bsfs 2>/dev/null | sed 1d))
+    bsfs=(${${(f)"$(ffmpeg -bsfs 2>/dev/null)"}:#*:})
     _ffmpeg_compadd 'set bitstream filter' bsfs ''
 }
 

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remove sed from _ffmpeg
  2010-09-16  8:38 [PATCH] remove sed from _ffmpeg Baptiste Daroussin
@ 2010-09-16  9:03 ` Peter Stephenson
  2010-09-16 12:12   ` Bapt
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2010-09-16  9:03 UTC (permalink / raw)
  To: zsh-workers

On Thu, 16 Sep 2010 10:38:31 +0200
Baptiste Daroussin <baptiste.daroussin@gmail.com> wrote:
> Here is a patch to remove sed from _ffmpeg.

I couldn't get this to apply and it looks a bit strange... the altered line
in _ffmpeg_formats doesn't appear to have a command or assignment on it
any more.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remove sed from _ffmpeg
  2010-09-16  9:03 ` Peter Stephenson
@ 2010-09-16 12:12   ` Bapt
  0 siblings, 0 replies; 3+ messages in thread
From: Bapt @ 2010-09-16 12:12 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 1020 bytes --]

On Thu, Sep 16, 2010 at 10:03:39AM +0100, Peter Stephenson wrote:
> On Thu, 16 Sep 2010 10:38:31 +0200
> Baptiste Daroussin <baptiste.daroussin@gmail.com> wrote:
> > Here is a patch to remove sed from _ffmpeg.
> 
> I couldn't get this to apply and it looks a bit strange... the altered line
> in _ffmpeg_formats doesn't appear to have a command or assignment on it
> any more.

Sorry I made a mistale in _ffmpeg_formats which is fixed by the following patch.

The patch is made using the latest git from sourceforge (git diff)

regards,
Bapt

> 
> -- 
> Peter Stephenson <pws@csr.com>            Software Engineer
> Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
> Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
> 
> 
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom

[-- Attachment #1.2: _ffmpeg_no_sed.diff --]
[-- Type: text/x-diff, Size: 1988 bytes --]

diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg
index 7c0660e..1c57e3b 100644
--- a/Completion/Unix/Command/_ffmpeg
+++ b/Completion/Unix/Command/_ffmpeg
@@ -18,24 +18,24 @@ _ffmpeg_presets() {
 
 _ffmpeg_acodecs() {
     local acodecs
-    acodecs=($(ffmpeg -codecs 2>/dev/null | sed -n '/^ .[E ]A/ {s/^ .......//; s/ .*//p;}'))
+    acodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _ffmpeg_compadd 'force audio codec (''copy'' to copy stream)' acodecs ''
 }
 
 _ffmpeg_vcodecs() {
     local vcodecs
-    vcodecs=($(ffmpeg -codecs 2>/dev/null | sed -n '/^ .[E ]V/ {s/^ .......//; s/ .*//p;}'))
+    vcodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
     _ffmpeg_compadd 'force video codec (''copy'' to copy stream)' vcodecs ''
 }
 
 _ffmpeg_formats() {
     local formats
-    formats=($(ffmpeg -formats 2>/dev/null | sed -e '1,/--/d' -e 's/^....//' -e 's/ .*//' | tr , '\n' | sort | uniq))
+    formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(ffmpeg -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
     _ffmpeg_compadd 'force format' formats ''
 }
 
 _ffmpeg_list_pix_fmts() {
-    ffmpeg -pix_fmts 2>/dev/null | sed -e '1,/-----/d' -e 's/^......//' -e 's/ .*//'
+    print -l ${${(M)${(f)"$(ffmpeg -pix_fmts 2>/dev/null)"}:#[I.]*}//(#b)??????([^[:space:]]##)*/$match[1]}
 }
 
 _ffmpeg_pix_fmts() {
@@ -46,7 +46,7 @@ _ffmpeg_pix_fmts() {
 
 _ffmpeg_bsfs() {
     local bsfs
-    bsfs=($(ffmpeg -bsfs 2>/dev/null | sed 1d))
+    bsfs=(${${(f)"$(ffmpeg -bsfs 2>/dev/null)"}:#*:})
     _ffmpeg_compadd 'set bitstream filter' bsfs ''
 }
 

[-- Attachment #2: Type: application/pgp-signature, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-16 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16  8:38 [PATCH] remove sed from _ffmpeg Baptiste Daroussin
2010-09-16  9:03 ` Peter Stephenson
2010-09-16 12:12   ` Bapt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).